Skip to content

Commit 3ea23e6

Browse files
v1.0.45
MAJOR UPDATE: - Added parameters to control script functions - Added the ability to move the slideshow to the next wallpaper - Added a native OFFLINE sunrise/sunset calculation system - Added a Desktop CONTEXT MENU to control the slideshow or theme - Fixed a problem where wallpapers would not change if a task was created without the need to change theme - Fixed geolocation (again) - Added verification of the config file to the setup script - Improved the Rainmeter sample skin - Many minor fixes
1 parent 15a88ba commit 3ea23e6

8 files changed

Lines changed: 832 additions & 623 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ jobs:
5959
# extract release notes from the script .NOTES section
6060
- name: Extract release notes from script
6161
run: |
62-
# Add 4 spaces to the start of the warning so it creates a code block too
63-
WARNING_MESSAGE=" (Make sure to edit the new Config.ps1 file before overwriting the old one.)"
62+
# --- add 4 spaces to the start of the warning (formats as code)
63+
# WARNING_MESSAGE=" (Make sure to edit the new \`at-config.ps1\` file before overwriting the old one.)"
6464
65-
# 1. Capture block. 2. Remove first/last line.
66-
# 3. Regex: Capture leading spaces (\1), match the hyphen/space, replace with just the leading spaces.
67-
RELEASE_NOTES=$(sed -n '/^.NOTES/,/^#>/p' at.ps1 | sed '1d;$d' | sed -E 's/^([[:space:]]*)-[[:space:]]*/\1/')
65+
# --- no spaces added (formats as italic text)
66+
WARNING_MESSAGE="_Make sure to edit the new \`at-config.ps1\` file before overwriting the old one._"
67+
68+
# --- This regex strips hyphens, keeps indent (formats as code) ---
69+
# RELEASE_NOTES=$(sed -n '/^.NOTES/,/^#>/p' at.ps1 | sed '1d;$d' | sed -E 's/^([[:space:]]*)-[[:space:]]*/\1/')
70+
71+
# --- this regex keeps hyphens, keeps indent (formats as code) ---
72+
# RELEASE_NOTES=$(sed -n '/^.NOTES/,/^#>/p' at.ps1 | sed '1d;$d')
73+
74+
# --- this regex keeps hyphens, removes the indent (formats as list) ---
75+
RELEASE_NOTES=$(sed -n '/^.NOTES/,/^#>/p' at.ps1 | sed '1d;$d' | sed 's/^[[:space:]]*//')
6876
6977
# Combine them.
7078
FULL_RELEASE_NOTES="$(printf "%s\n\n%s" "$RELEASE_NOTES" "$WARNING_MESSAGE")"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.user
1010
*.userosscache
1111
*.sln.docstates
12+
context-menu.reg
1213

1314
# User-specific files (MonoDevelop/Xamarin Studio)
1415
*.userprefs

README.md

Lines changed: 84 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
# AUTO THEME
33
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.
44

@@ -13,11 +13,15 @@ If using `.theme` files and the standard Windows slideshow, displaying wallpaper
1313

1414
**Auto Theme** is designed to run in the background as a scheduled task, ensuring that the system theme is updated without user intervention.
1515

16-
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.
16+
This script operates <ins>almost entirely offline</ins>. It only connects to the internet to verify Location, in the case this is not retrivable from the system or is not provided by the user in the config file.
17+
18+
Sunrise and sunset calculations are done locally (optionally the user can request this via free api services such as sunrisesunset.io, but it is mostly unnecessary.)
1719

18-
It can also stay completely offline by operating on fixed hours provided by the user.
20+
Alternatively, the script can operate on fixed hours provided by the user.
1921

20-
When run from terminal, using the `.\at.ps1`[^2] command, the script will 'toggle' the theme mode and then exit, ignoring any scheduled event.
22+
**Auto Theme** includes a Desktop context menu to control the slideshow, toggle the theme or refresh the sunrise/sunset schedule. This is first created via the setup script, but can be disabled in the configuration file, and/or removed using the included `.reg` file in the repository.
23+
24+
When run from terminal, using the `./at.ps1 --Toggle`[^2] command (or just `./at.ps1` with no parameters), the script will 'toggle' the theme mode and then exit, <ins>ignoring any scheduled event</ins>.
2125

2226
![GIF 13 03 2025 1-30-58](https://github.com/user-attachments/assets/5ea7e34d-4e55-4cd4-a629-73f92ef2436c "The command can be run in terminal in verbose mode.")
2327
<br /><sup>The command `.\at.ps1` can be run in terminal in verbose mode.</sup>
@@ -37,20 +41,20 @@ When run from terminal, using the `.\at.ps1`[^2] command, the script will 'toggl
3741
<br /><sup>In the Personalize>Themes windows, right click on a theme and select 'Save for sharing'.</sup>
3842
- Indicate the paths to the `.theme files` in the config file
3943

40-
4) (optional) Run the script `.\at-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.
44+
4) Run the script `./at-setup.ps1`[^2] to create the main scheduled task and the desktop context menu. The script will ask for system privileges if not run as admin, and then proceed to create and launch the "Auto Theme" task.
4145

4246
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:
43-
- Program/script: `Powershell.exe`
44-
- Add arguments: `-WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -NoProfile -File "C:\path\to\at.ps1"`
45-
- Run with highest privileges.
47+
- Program/script: `conhost.exe`
48+
- Add arguments: `--headless Powershell.exe -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -NoProfile -File "C:\path\to\at.ps1"`
49+
- Run with highest privileges.
4650
<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>
4751

4852
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.
4953

5054
## Usage
5155
This script is designed to run from Task Scheduler, and after the initial setup doesn't need interaction from the user.
5256

53-
The Scheduled tasks can run the script in a completely hidden manner, or in a visible way, per user choice.
57+
The Scheduled tasks can run the script in a completely hidden manner, or visibly, per user choice.
5458

5559
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\at.ps1"`, indicating the same path in the `Start in` field:
5660
<p><img width="532" height="540" alt="A Windows shortcut can be created to directly toggle the theme." src="https://github.com/user-attachments/assets/b85cb2d7-91b1-44ef-90d4-b504b74c40df" />
@@ -59,11 +63,75 @@ For convenience, a shortcut to the script can be created and placed on the deskt
5963
## Extra apps
6064
Workarounds have been added for a number of apps which do not toggle theme gracefully when the system theme changes. More details in the Config file.
6165

62-
&nbsp;
63-
64-
<p align=center>Why, thank you for asking!<br />👉 You can donate to all my projects <a href="https://www.buymeacoffee.com/unalignedcoder" target="_blank" title="buymeacoffee.com">here</a>👈</p>
65-
66-
&nbsp;
67-
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.
66+
<p>&nbsp;</p>
67+
68+
<div align="center"><table border="1" cellspacing="0" cellpadding="20"><tr><td><p align="center">&nbsp;<br>Why, thank you for asking!</p><hr width="60%"><p align="center">👉 You can donate to all my projects <a href="https://www.buymeacoffee.com/unalignedcoder" target="_blank">here</a> 👈<br>&nbsp;</p></td></tr></table></div>
69+
70+
<p>&nbsp;</p>
71+
72+
73+
74+
### v1.0.45 (2026-01-13)
75+
MAJOR UPDATE:
76+
- Added parameters to control script functions
77+
- Added the ability to move the slideshow to the next wallpaper
78+
- Added a native OFFLINE sunrise/sunset calculation system
79+
- Added a Desktop CONTEXT MENU to control the slideshow or theme
80+
- Fixed a problem where wallpapers would not change if a task was created without the need to change theme
81+
- Fixed geolocation (again)
82+
- Added verification of the config file to the setup script
83+
- Improved the Rainmeter sample skin
84+
- Many minor fixes
85+
### v1.0.43
86+
- Fixed a problem that caused the wallpaper not to change if the PC was off a long time
87+
- Improved the at-setup.ps1 script for the creation of the main scheduled task
88+
- Many minor fixes
89+
90+
### v1.0.42
91+
- Fixed loading/unloading of Rainmeter skins
92+
- Added description to the Scheduled Tasks
93+
- Attempt to correct suspect interference with Power settings
94+
- Several minor fixes
95+
96+
### v1.0.40
97+
MAJOR UPDATE:
98+
- Added a native system to load Dark or Light modes and randomize wallpapers.
99+
- Renamed the script `at.ps1` for consistency with my other "short-named" projects.
100+
- Changed the names of the generated tasks, make sure you delete the old ones in Task Scheduler.
101+
- Added a "wrapper" script (`AutoTheme.ps1`) for compatibility with older tasks and existing shortcuts.
102+
- Added a worker script (`at-wallpaper.ps1`) to handle the wallpaper slideshow natively via Task Scheduler.
103+
- Fixed a problem with the script not recognizing it was running from Task Scheduler
104+
- Improved geolocation
105+
- Removed the MusicBee restart option, as not really helpful
106+
- Many minor fixes
107+
108+
### v1.0.37
109+
- Added logic to completely hide the console window when ran from Scheduler, or use Windows Terminal
110+
- Fixed an issue with possible user identity spoofing when creating Scheduled Tasks, in main and setup scripts
111+
- Scheduked Tasks are now created with battery settings to avoid the script being blocked on laptops
112+
- Added logic to control elevation privileges of restarted apps.
113+
114+
### v1.0.33
115+
- Corrected a problem with Taskbar colorization
116+
- Improved variables in config file
117+
118+
### v1.0.32
119+
- Added T-Clock to extra apps and Fixed theme switching issues with it.
120+
- Changed function names to appease PS standards. Sigh.
121+
- Several minor improvements and fixes.
122+
123+
### v1.0.27
124+
- Improved the renaming of random wallpapers.
125+
- Simplified/optimized several functions.
126+
- Optionally show the wallpaper filename in notifications, when the theme changes.
127+
- Added MusicBee to the apps that can be optionally restarted upon theme change.
128+
- Minor fixes.
129+
130+
### v1.0.19
131+
- Improved the release-creation system
132+
- Minor fixes
133+
134+
## Footnotes
135+
[^1]: `.theme` files are simple configuration instructions for the Windows pesonalization engine. You can find two examples included in this repository, with helpful comments.
69136
[^2]: To run a PowerShell script on Windows, you need to set `Execution Policy` in PowerShell, using this command: `Set-ExecutionPolicy RemoteSigned` as Administrator.
137+

at-config.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@
9696
$sunriseOffset = 0
9797
$sunsetOffset = 0
9898

99+
# ============= Context menu =============
100+
101+
<# If `$true`, adds an 'Auto Theme' context menu on desktop.
102+
This allows you to show the next wallpaper in the slideshow,
103+
quickly switch between Light and Dark modes on demand,
104+
or refresh the Scheduled Tasks.
105+
It may requires a restart of Explorer to take effect. #>
106+
$addContextMenu = $true
107+
99108
# ============= Extra apps variables =============
100109

101110
<# Sysinternals Process Explorer doesn't automatically change theme when the system theme is changed. Use this variable if you want it to be restarted.
@@ -149,7 +158,7 @@
149158
# Write Wallpaper name in Registry for other apps or scripts to read
150159
$writeRegistry = $false
151160

152-
# ============= Shared Win32 API & Power Management ==============
161+
# ============= Shared Win32 API & Power Management, for wallpaper changing ==============
153162

154163
$Win32Code = @'
155164
using System;

at-rainmeter.ini

392 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)