-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathat-config.ps1
More file actions
191 lines (150 loc) · 8.5 KB
/
at-config.ps1
File metadata and controls
191 lines (150 loc) · 8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# ============= Theme variables =============
<# If `$true`, the script will use `.theme` files to select light and dark themes, as well as wallpaper slideshows and other personalizations. If `$false`, it will use its own native system to switch between dark and light modes, and implement a wallpaper slideshow accordingly. #>
$useThemeFiles = $false
<# Name of theme files
* Only relevant when `$useThemeFiles = $true` #>
$themeLight = "Name-of-Light.theme"
$themeDark = "Name-of-Dark.theme"
<# COMPLETE PATH to the `.theme` files. You can use the default path to Windows themes
(as proposed in the example below) or a custom path of your choice.
You can use `$lightPath = Join-Path $PSScriptRoot $themeLight`
if your `.theme` files are located within the script folder.
* Only relevant when `$useThemeFiles = $true` #>
$lightPath = Join-Path (Join-Path $Env:LOCALAPPDATA "Microsoft\Windows\Themes") $themeLight
$darkPath = Join-Path (Join-Path $Env:LOCALAPPDATA "Microsoft\Windows\Themes") $themeDark
# ============= Wallpaper variables =============
<# If `$true`, the script will only switch between Dark and Light modes, ignoring wallpapers.
* Only relevant when `$useThemeFiles = $false` #>
$noWallpaperChange = $false
<# Randomize wallpaper - when NOT using `.theme` files.
If `$true`, picks a random wallpaper from the wallpaper paths.
* Only relevant when `$useThemeFiles = $false` #>
$randomizeWallpaper = $true
<# Interval at which to randomize wallpapers. This effectively replaces Windows' own slideshow feature.
This will create a specific Scheduled task to handle wallpaper changes at the defined interval.
Set to "0" to disable this feature.
* Only relevant when `$useThemeFiles = $false` #>
$slideShowInterval = "0" # minutes
<# Display the wallpaper name when it changes.
"rainmeter" - Displays the name as on overlay, via Rainmeter (a 'skin' is provided as example.)
"notification" - Shows a Windows BurntToast notification.
"none" - Changes the wallpaper with no UI feedback.
* Only relevant when `$useThemeFiles = $false`
Note: To achieve the same effect when using `.theme` files or the Windows standard slideshow, check my Wallpaper Name Notification script on Github. #>
$howToDisplayName = "none"
<# Path to Rainmeter executable
* Only relevant when `$useThemeFiles = $false` #>
$rainmeterPath = "C:\Program Files\Rainmeter\Rainmeter.exe"
<# The Config Name of your Rainmeter skin.
This is the relative path from your 'Skins' folder to the folder containing the `.ini` file.
Example: If the skin is in 'Skins\AutoTheme\Wallpaper\at.ini', use "AutoTheme\Wallpaper"
You can find in the repository a functional example of a skin that shows the wallpaper name at the bottom of the screen. #>
$rainmeterSkinName = "AutoTheme\Wallpaper"
$rainmeterSkinFile = "at.ini"
<# Randomize FIRST wallpaper - when using `.theme` files AND shuffling wallpapers.
Even if `shuffle=1` is set in a `.theme` file, Windows will always use the first wallpaper in alphabetic order as the first shown.
Setting this to `$true` offers more variety as soon as the theme is applied.
Be aware that, to this end, a randomly-picked wallpaper file will be temporarily renamed with a `0_at` string prepended to it.
* Only relevant when `$useThemeFiles = $true` #>
$randomFirst = $true
<# Paths to the folders for light and dark wallpapers.
If `$useThemeFiles = $true`, indicate here the same FOLDER PATHS indicated in the `.theme` files.
If `$useThemeFiles = $false`, indicate PATHS to IMAGES OR FOLDERS to be selected for Light and Dark modes. #>
$wallLightPath = "C:\Path\to\Light\wallpapers"
$wallDarkPath = "C:\Path\to\Dark\wallpapers"
# Show the wallpaper name in notification
$showWallName = $true
# ============= Time variables =============
# Use fixed hours to switch Themes (keeps the script completely offline)
$useFixedHours = $false
<# Fixed hours for theme change (only needed if $useFixedHours = $true).
You are free to use 12 or 24 hours formats here. #>
$lightThemeTime = "07:00 AM"
$darkThemeTime = "07:00 PM"
<# Set to `$true` to always use a user-defined location.
If `$false`, the script will attempt to retrieve location from the system
or, failing that, from your ISP, which may not give accurate results. #>
$useUserLoc = $false
<# User-defined coordinates and timezone. You can obtain your coordinates from Google or similar services.
You can find a list of timezone identifiers at this url:
https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
* Only relevant if `$useUserLoc = $true`#>
$userLat = "40.7128"
$userLng = "-74.0060"
$UserTzid = "America/New_York"
<# Add or remove minutes to Sunrise and Sunset times. This can help to account for local peculiarities. Values can be negative, for example, -30 means the event triggers 30 minutes earlier. #>
$sunriseOffset = 0
$sunsetOffset = 0
# ============= Context menu =============
<# If `$true`, adds an 'Auto Theme' context menu on desktop.
This allows you to show the next wallpaper in the slideshow,
quickly switch between Light and Dark modes on demand,
or refresh the Scheduled Tasks.
It may requires a restart of Explorer to take effect. #>
$addContextMenu = $true
# ============= Extra apps variables =============
<# Sysinternals Process Explorer doesn't automatically change theme when the system theme is changed. Use this variable if you want it to be restarted.
If you run Process Explorer as Admin, the script should also run as Admin for this to work.
You can use the $forceAsAdmin variable below for the purpose. #>
$restartProcexp = $false
# If `$true`, Process Explorer will keep Admin rights (inheriting from this script).
# If `$false`, it will be restarted as a standard user. All other apps are restarted as standard user.
$restartProcexpElevated = $true
<# Change TrueLaunchBar colors (will cause Explorer to be restarted.)
Look into the 'Update-TrueLaunchBar-colors' function for more details #>
$customizeTrueLaunch = $false
$trueLaunchIniFilePath = Join-Path $Env:APPDATA "Tordex\True Launch Bar\settings\setup.ini"
<# Changes color in the T-Clock font, so that it adapts to the current theme.
When T-Clock redraws the clock background based on accent color, it may cause the taskbar to crash or flicker. #>
$tClockPath = "C:\Path\to\T-Clock\Clock64.exe"
$updateTClockColor = $false
$restartTClockColor = $false # usually not needed
# ============= Developer variables ==============
$log = $true
$logFromTerminal = $false
$trimLog = $true
$verbose = $false
$lastRunInterval = "5"
$waitExplorer = "30"
$checkLastRun = $true
$maxLogEntries = "5"
# Try turning accent color off for Taskbar if you have surge issues when switching theme or wallpaper
$turnOffAccentColor = $false
$restartThemeService = $false
$forceAsAdmin = $false
# required files
$appLogo = Join-Path $PSScriptRoot "at.png"
$logFile = Join-Path $PSScriptRoot "at.log"
$lastRunFile = Join-Path $PSScriptRoot "atLastRun.txt"
$workerPath = Join-Path $PSScriptRoot "at-wallpaper.ps1"
<# Console Visibility Settings when run from Task Scheduler:
* "ch"- Completely hidden (no flash) using `conhost --headless`
* "ps"- Standard PowerShell window (may flash briefly)
* "wt"- Opens in Windows Terminal (using existing window if open) #>
$terminalVisibility = "ch"
# Write Wallpaper name in Registry for other apps or scripts to read
$writeRegistry = $false
# ============= Shared Win32 API & Power Management, for wallpaper changing ==============
$Win32Code = @'
using System;
using System.Runtime.InteropServices;
public class WinAPI {
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd, uint Msg, IntPtr wParam, string lParam,
uint fuFlags, uint uTimeout, out IntPtr lpdwResult);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern uint SetThreadExecutionState(uint esFlags);
}
'@
# Load the API class if not already present
if (-not ([System.Management.Automation.PSTypeName]'WinAPI').Type) {
Add-Type -TypeDefinition $Win32Code -ErrorAction SilentlyContinue | Out-Null
}
# Apply Background Power State immediately upon loading config
# This prevents any script using this config from blocking monitor/system sleep.
try {
[WinAPI]::SetThreadExecutionState([System.UInt32]2147483648) | Out-Null
} catch { }