Created
September 3, 2020 15:31
-
-
Save Amaimersion/62d1bcb13acee31c27c78dcf225b5f84 to your computer and use it in GitHub Desktop.
Windows Auto Dark Mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Create windows task to run this script: | |
1) Add multiple triggers: | |
- at system startup | |
- at 9 AM every day (your desired time to disable dark mode) | |
- at 9 PM every day (your desired time to enable dark mode) | |
2) Add an action: | |
Action = Start a program | |
Program/script = <path to python3> (example: "D:\Python\Python-3.8.3\python.exe") | |
Arguments = <path to this script> (example: "D:\Auto-Dark-Mode\main.py") | |
3) Edit conditions: | |
Start the task only if the computer is on AC power = OFF | |
4) Edit settings: | |
Run task as soon as possible after a scheduled start is missing = ON | |
""" | |
import time | |
from subprocess import check_output | |
local_time = time.localtime(time.time()) | |
current_hour = local_time.tm_hour | |
reg = "reg add HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize /v AppsUseLightTheme /t REG_DWORD /d {value} /f" | |
reg_value = 1 | |
# your desired time to enable dark mode | |
if ( | |
(21 <= current_hour <= 23) or | |
(0 <= current_hour < 9) | |
): | |
reg_value = 0 | |
reg = reg.format(value=reg_value) | |
check_output(reg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment