Up: macOS
This toggles between light and dark mode, and sets the appropriate wallpaper — expects two image aliases light and dark, in ~/Pictures/System:
tell application "System Events"
log "hello"
tell appearance preferences
set dark mode to not dark mode
set isDark to dark mode
end tell
end tell
if isDark is true then
set pictureFile to (path to pictures folder from user domain as string) & "System:dark"
else
set pictureFile to (path to pictures folder from user domain as string) & "System:light"
end if
tell application "Finder"
set resolvedPath to ((original item of (pictureFile as alias)) as text)
end tell
tell application "System Events"
tell every desktop
set picture to resolvedPath
end tell
end tell