Skip to content

Instantly share code, notes, and snippets.

@erichnascimento
Created July 26, 2014 04:15
Show Gist options
  • Save erichnascimento/d83d0825bd7f340f30c6 to your computer and use it in GitHub Desktop.
Save erichnascimento/d83d0825bd7f340f30c6 to your computer and use it in GitHub Desktop.
A simple gnome desktop background changer even given time
#!/usr/bin/env bash
# author: Erich Nascimento <[email protected]>
# created: 2014-07-26 01:25
# TODO: Implements transitions maybe using gsettings ... picture-opacity
#
# references:
# - Inspiration: http://askubuntu.com/a/69500/184517
# - Scripting approach: https://github.com/visionmedia/n/blob/master/bin/n
# - Sleep: http://www.cyberciti.biz/faq/linux-unix-sleep-bash-scripting/
# - Default param: http://www.tldp.org/LDP/abs/html/parameter-substitution.html
# - Loop over files: http://www.cyberciti.biz/faq/bash-loop-over-file/
#
# Sorry my poor english. LOL
#
# Usage
#
# You can export 2 vars in your ~/.bash_profile :
# Define image dir to iterate. Default /usr/share/backgrounds
# export GNOME_BG_CARROUSEL_DIR=~/Pictures
# Define duration time. Default 10s
#export GNOME_BG_CARROUSEL_DURATION=30s
#
# Initialize
#
IMAGES_DIR=${GNOME_BG_CARROUSEL_DIR-/usr/share/backgrounds}
DURATION=${GNOME_BG_CARROUSEL_DURATION-10s}
#
# Ensure we have gsettings installed
#
GSETTINGS=
command -v gsettings > /dev/null && GSETTINGS="gsettings"
test -z "$GSETTINGS" && printf "\n \033[31mError: gsettings is required :( \033[0m\n\n" && exit 1
# Infinite looping
while true; do
for file in $IMAGES_DIR/*
do
[ -f "$file" ] && gsettings set org.gnome.desktop.background picture-uri "file://$file"
sleep $DURATION
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment