Saturday, June 7, 2014

Cinnamon Wallpaper Shell Script

A little shell script to change wallpaper in Cinnamon

Copy the following script and modify it accordingly:
#!/bin/sh
# Script variables
DIR="/home/linuxmint/Pictures"               # Directory contains wallpaper

WALLPAPER=$(ls $DIR/*.png | shuf -n1)    # File extension is set to *.png
echo $WALLPAPER                          # Debug
gsettings set org.cinnamon.desktop.background picture-uri "file:$WALLPAPER"
 


Save the script as wallpaper.sh, and set the file permission to 755.
Then you can run it from your terminal and start debugging.
Once you are happy with it, add it to your crontab (including DISPLAY=:0)
The one below runs every 5 minutes:
*/5 * * * * DISPLAY=:0 /home/linuxmint/script/wallpaper.sh

To debug, you can run the following commands directly:
gsettings set org.cinnamon.desktop.background picture-uri "file:/home/linuxmint/Pictures/snsd01.png"
gsettings get org.cinnamon.desktop.background picture-uri
  
That's it!