Random desktop background from command line
As mentioned in my previous post I synchronize my wallpaper folder between my desktop computers. While the are various ways of setting a random desktop background (XFCE - which I use - has this built in), I’ve had to conclude it’s just easier from the command line. In XFCE it is not possible to do this from cron it seems, so I made a script which is run at start-up: #!/bin/bash IFS=' ' # Change this to where the wallpapers are stored DIR="$HOME/Pictures/wallpaper" while true do PIC=$(ls $DIR/*.* | shuf -n1) #PIC2=$(ls $DIR/*.* | shuf -n1) # Uncomment based on desktop environment # XFCE: #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-show -s true #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s ${PIC} #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 5 #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-show -s true #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-path -s ${PIC2} #/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor1/image-style -s 5 # GNOME2 #gconftool-2 --type=string --set /desktop/gnome/background/picture_filename ${PIC} #gconftool-2 --type=string --set /desktop/gnome/background/picture_options zoom # GNOME/Unity/Cinnamon gsettings set org.gnome.desktop.background picture-uri file://${PIC} gsettings set org.gnome.desktop.background picture-options zoom # MATE #gsettings set org.mate.background picture-filename ${PIC} #gsettings set org.mate.background picture-options zoom # GNOME screen saver gsettings set org.gnome.desktop.screensaver picture-uri file://${PIC} gsettings set org.gnome.desktop.screensaver picture-options zoom # Generic - uses feh #feh --bg-fill ${PIC} sleep 60 done To enable auto-start, add the file ~/.config/autostart/Set_wallpaper.desktop with this content: ...