Tengo carpetas de papel tapiz llamadas Day
y Night
, y estoy trabajando en un script que alternará el modo oscuro y cambiará la carpeta del papel tapiz en consecuencia. Sin embargo, no puedo averiguar cómo cambiar la carpeta del fondo de pantalla programáticamente, y habilitar "cambiar la imagen cada minuto" y "orden aleatorio".
Respuesta
¿Demasiados anuncios?
balupton
Puntos
111
Resulta que https://stackoverflow.com/a/39208361/130638 es la magia.
Aquí está mi guión completo :
#!/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