1

I have wallpaper folders called Day and Night, and I am working on a script that will toggle dark mode and change the wallpaper folder accordingly. However, I can't figure out how to programatically change the wallpaper folder, and enable "change picture every minute" and "random order".

2

Turns out https://stackoverflow.com/a/39208361/130638 is the magic.

Here is my completed script:

#!/usr/bin/env bash
source "$HOME/.scripts/sources/strict.bash"
# https://apple.stackexchange.com/a/326863/15131
# https://stackoverflow.com/a/39208361/130638

function wallpaper {
    path="/Users/balupton/Documents/Media/Media - Wallpapers/High Quality/Time/$1"
    osascript -e 'tell application "System Events" to tell current desktop to set pictures folder to "'"$path"'"'
}

if is-affirmative "${1:-}" "yes"; then
    echo 'enabling dark mode...'
    osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true'
    wallpaper Night
elif is-affirmative "${1:-}" "no"; then
    echo 'disabling dark mode...'
    osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to false'
    wallpaper Day
else
    echo 'toggling dark mode...'
    osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'
    wallpaper Popping
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .