Last active
April 11, 2017 14:21
-
-
Save doublecompile/c2925a4a570c991af60d to your computer and use it in GitHub Desktop.
Rotates a wallpaper on either Gnome or OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Rotate wallpapers on GNOME or OSX | |
# (OSX users need to install coreutils) | |
set -e | |
WALLPAPERS="$HOME/wallpaper" | |
if [[ -n "$(command -v gsettings)" ]]; then | |
paper=`find $WALLPAPERS -type f | shuf -n 1` | |
PID=$(pgrep gnome-session) | |
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-) | |
gsettings set org.gnome.desktop.background picture-uri "file:///$paper" | |
elif [[ -n "$(command -v osascript)" ]]; then | |
paper=`find $WALLPAPERS -type f | gshuf -n 1` | |
osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"$paper\"" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I also have a cron entry: