Change Desktop Wallpaper per Commandline

I wanted to change my desktop wallpaper with one click at the toolbar - so I needed a shell script to do this. I came up with this:


PIC=$(ls $DIR | shuf -n1)
dconf write /org/mate/desktop/background/picture-filename "'$CMPL'"

I use Wallhaven to find some nice wallpapers. Basically the script just ls into your wallpaper directory and pipes the ls output to shuf. It then changes the value for the picture-filename key.

If you want to change your wallpaper after a given time, you could use cron jobs to do this, or just run another script:

while true; do
	sleep 600

The script above just executes the script every 5 minutes.

I hope this helped you - if so leave a comment! :)