Gnome3 Wallpaper script

From Jonsdocswiki
Jump to: navigation, search

This script will change your Gnome3 background image after a set period (defined by change=). At present only JPG images with an extension of jpg are shuffled.

User options

change - set to the number of minutes you want between changes
wallpapers - set to the path to a directory containing JPG wallpapers.

Script code

#!/bin/bash
set -e
#: Title            : wallpaper-for-gnome3
#: Date             : March 2014
#: Author           : Jonathan Haddock and Sharon Kimble (original version for another Desktop Environment)
#: Version          : 1.0
#: Description      : changes your wallpaper, and can be run from an alias
####################################################
#: Options          : 
# change - length of time (minutes) before the wallpaper changes again
# wallpapers - path to Wallpapers directory containing JPG files
#; Requirements     : shuf, gsettings (gnome 3)
#: License          : GNU GPL 3.0 or later
####################################################
# Options
change=10
wallpapers=/home/jonathan/Wallpapers
###################################################
while true; do
  BGFILE=`find $wallpapers -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |	shuf -n1 -z`
	gsettings set org.gnome.desktop.background picture-uri file://$BGFILE
	gsettings set org.gnome.desktop.background picture-options stretched #stretched, scaled, zoom, centered, none, spanned, wallpaper
   sleep "$change"m
done

Acknowledgements

Original script, for a different desktop environment, from Boudiccas' site a taste of Linux - Wallpaper v1

Personal tools