Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Fetches a random wallpaper from /r/wallpapers
- # and sets xfdesktop's wallpaper to it
- #
- # Author: Michael Koch (emkay443) (and others on reddit: http://redd.it/25wkxa)
- # Version: 2014-05-19_1
- # License: GPL v3
- # get XDG variables
- . $HOME/.config/user-dirs.dirs
- # configuration
- wp_file=$XDG_PICTURES_DIR/wpotd
- random=true
- monitors=( 0 1 )
- # helper variable
- if $random; then
- url=$(curl -s http://www.reddit.com/r/wallpapers/.rss | grep -o "http://i.imgur.com/[/a-zA-Z0-9.]\+" | shuf -n 1)
- else
- url=$(curl -s http://www.reddit.com/r/wallpapers/.rss | grep -o "http://i.imgur.com/[/a-zA-Z0-9.]\+" | head -1)
- fi
- # download image
- wget -O $wp_file "$url"
- # make sure, DBUS is loaded correctly (make this script work with cron)
- if [ -z "${DBUS_SESSION_BUS_ADDRESS}" ] ; then
- . ${HOME}/.dbus/session-bus/`ls -rt ${HOME}/.dbus/session-bus/ | tail -1`
- export DBUS_SESSION_BUS_ADDRESS
- fi
- for mon in "${monitors[@]}"; do
- # set xfdesktop's wallpaper and refresh
- DISPLAY=:0 xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor$mon/image-path -s $wp_file
- DISPLAY=:0 xfdesktop --reload
- done
Add Comment
Please, Sign In to add comment