You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-27Lines changed: 26 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,47 +2,54 @@
2
2
Powershell script which changes the active Windows theme and Desktop background based on daylight or a predefined schedule. Works in Windows 10/11. Not tested in Windows 7.
3
3
4
4
## Description
5
-
This script automatically switches the Windows active theme depending on Sunrise and Sunset, or hours set by the user.
5
+
This script automatically switches the Windows active theme depending on Sunrise and Sunset daylight times, or hours set by the user.
6
6
7
-
Rather than relying on registry/system settings, it works by activating `.theme` files. This allows for a much higher degree of customization and compatibility.
7
+
It directly activates Windows Light and Dark modes at these times, and handles its own native dedicated wallpapers slideshows for each.
8
8
9
-
It is designed to run in the background as a scheduled task, ensuring that the system theme is updated without user intervention.
9
+
Alternatively, it can work by activating dedicated `.theme` files. This may allow for a higher degree of customization and compatibility on certain systems.
10
+
11
+
**Auto Theme** is designed to run in the background as a scheduled task, ensuring that the system theme is updated without user intervention.
10
12
11
13
It only connects to the internet to verify Location and retrieve Sunrise and Sunset times, via free api services such as sunrisesunset.io and ip-api.com.
12
14
13
-
Alternatively, it can stay completely offline operating on fixed hours provided by the user.
15
+
It can also stay completely offline by operating on fixed hours provided by the user.
14
16
15
-
When run as the command `.\AutoTheme.ps1` from terminal or desktop shortcut, the script toggles between themes, ignoring scheduled events.
17
+
When run as the command `.\at.ps1` from terminal or desktop shortcut, the script toggles between themes, ignoring scheduled events.
16
18
17
19
## Installation
18
20
1) Download the latest [release](https://github.com/unalignedcoder/auto-theme/releases) and extract it to your preferred folder.
19
-
2) Create custom **Light** and **Dark** themes. To do so, simply modify settings in the _Personalize_ window (including colors or, for example, a wallpaper slideshow) and then save the theme.
20
-
(`.theme` files are simple configuration instructions for the Windows pesonalization engine. You can find two examples of them included in this repository, with helpful comments.)
21
21
22
-

23
-
<br /><sup>In the Personalize>Themes windows, right click on a theme and select 'Save for sharing'.</sup>
24
-
4) Open the file `Config.ps1` and modify variables as preferred:
22
+
2) Open the `Config.ps1` file and modify variables as preferred:
25
23
26
24

27
25
<br /><sup>All entries in the config file come with exhaustive explanations.</sup>
26
+
27
+
3) If using `.theme` files[^1]:
28
+
- Make sure `$useThemeFiles = $true` is set in the config file;
29
+
- Modify settings in the _Personalize_ window (including colors or, for example, a wallpaper slideshow) and then save the theme;
30
+

31
+
<br /><sup>In the Personalize>Themes windows, right click on a theme and select 'Save for sharing'.</sup>
32
+
- Indicate the paths to the `.theme files` in the config file
28
33
29
-
5) (optional) Run the script `.\Setup.ps1`[^1] to create the main scheduled task. The script will ask for system privileges if not run as admin, and then proceed to create the "Auto Theme" task.
34
+
4) (optional) Run the script `.\Setup.ps1`[^2] to create the main scheduled task. The script will ask for system privileges if not run as admin, and then proceed to create the "Auto Theme" task.
30
35
31
36
6) (alternative) You can of course create the task yourself using Task Scheduler, setting the triggers to anything you prefer. In this case, make sure that the Action is set up as follows:
<b>It is advisable to always add the "On Workstation Unlock" trigger to the task. When the workstation is locked, the task may be unable to apply the theme fully, leaving out slideshow customizations and resulting in a hybrid "Custom" theme.</b> The tasks can run the script in a completely hidden manner, or in a visible way, per user choice.
40
+
<b>It is advisable to always add the "On Workstation Unlock" trigger to the task. When the workstation is locked, the task may be unable to apply the theme fully, leaving out slideshow customizations and resulting in a hybrid "Custom" theme.</b>
36
41
37
-
7) When triggered, the task will then run the script `AutoTheme.ps1`. The script itself will schedule the next temporary task ("Sunrise Theme" or "Sunset theme") to run at the next required theme change time, whether set by the user or identified through user location.
42
+
7) When triggered, the task will then run the script `at.ps1`. The script itself will schedule the next temporary task ("Sunrise Theme" or "Sunset theme") to run at the next required theme change time, whether set by the user or identified through user location. These task will be overwritten as a matter of course, to avoid clutter.
38
43
39
44
## Usage
40
-
This script is designed to run from Task Scheduler, and after the initial setup doesn't need interaction from the user.
45
+
This script is designed to run from Task Scheduler, and after the initial setup doesn't need interaction from the user.
41
46
42
-
When run from terminal, using `.\AutoTheme.ps1`[^1], the script will 'toggle' the theme (switching from one `.theme` file to the other) and then exit, ignoring any scheduled event. This can be useful for testing purposes, but also for the odd times when there is need to manually switch the theme regardless of task settings.
47
+
The Scheduled tasks can run the script in a completely hidden manner, or in a visible way, per user choice.
48
+
49
+
When run from terminal, using `.\at.ps1`[^2], the script will 'toggle' the theme mode and then exit (optionally modifying wallpapers), ignoring any scheduled event. This can be useful for testing purposes, but also for the odd times when there is need to manually switch the theme regardless of task settings.
43
50
44
51

45
-
<br /><sup>The command `.\AutoTheme.ps1` can be run in terminal in verbose mode.</sup>
52
+
<br /><sup>The command `.\at.ps1` can be run in terminal in verbose mode.</sup>
46
53
47
54
For convenience, a shortcut to the script can be created and placed on the desktop or taskbar for quick access. In this case, the shortcut should be to `powershell.exe` followed by the path to the script `"C:\path\to\AutoTheme.ps1"`, indicating the same path in the `Start in` field:
48
55
@@ -58,15 +65,7 @@ Workarounds have been added for a number of apps which do not toggle theme grace
58
65
59
66
60
67
61
-
## The forgotten benefits of using `.theme` files
62
-
Many scripts and apps try to automate dark and light theme functionality under Windows 10/11, but they do so by directly modifying system behavior, incurring in many difficulties and potential compatibility problems for the user.
63
-
64
-
This script however directly starts `.theme` files as processes (as if the user double-clicked on them), therefore letting Windows itself operate the entire visual transition, be it just the application of dark mode, or with addition of visual styles, wallpapers and more.
65
-
66
-
In fact, in addition to switching light and dark themes, using `.theme` files allows to set different wallpaper slideshows for each theme, while including other changes such as cursors, sounds, and more, all without forcing or tricking the system into unusual behavior.
67
-
68
-
All it takes are two `.theme` files (very easy to create, see Installation instructions above.)
69
-
70
-
[^1]: To run a PowerShell script on Windows, you need to set Execution Policy in PowerShell, using this command: `Set-ExecutionPolicy RemoteSigned` as Administrator.
68
+
[^1]: `.theme` files are simple configuration instructions for the Windows pesonalization engine. You can find two examples included in this repository, with helpful comments.
69
+
[^2]: To run a PowerShell script on Windows, you need to set `Execution Policy` in PowerShell, using this command: `Set-ExecutionPolicy RemoteSigned` as Administrator.
0 commit comments