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=' ' DIR="$HOME/etc/wallpaper" # Uncomment based on desktop environment # XFCE: #SET="/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s " #SET2="/usr/bin/xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 5 " # GNOME2 #SET="gconftool-2 --type=string --set /desktop/gnome/background/picture_filename " #SET2="gconftool-2 --type=string --set /desktop/gnome/background/picture_options zoom" # GNOME/Unity #SET="gsettings set org.gnome.desktop.background picture-uri file://" #SET2="gsettings set org.gnome.desktop.background picture-options zoom" # Generic - uses feh #SET="feh --bg-fill " #SET2="" while true do PIC=$(ls $DIR/*.* | shuf -n1) ${SET}$PIC ${SET2} # Sets image style to zoom sleep 120 done
In order to make the script run at start-up, create the file $HOME/.config/autostart/wallpaper.desktop
[Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=Rotate bg Comment= Exec=/home/alj/bin/setwallpaper.sh StartupNotify=false Terminal=false Hidden=false
If you are not using a desktop environment like GNOME or XFCE, add the script to .xsession.












