Skip to content

Instantly share code, notes, and snippets.

@Soft
Last active August 29, 2015 13:57
Show Gist options
  • Save Soft/9814846 to your computer and use it in GitHub Desktop.
Save Soft/9814846 to your computer and use it in GitHub Desktop.
Script for managing multiple wallpapers
#!/usr/bin/env bash
CONFIG=$HOME/.config/nitrogen
SETS=$CONFIG/sets
function setWallpaper {
[ ! -f "$SETS/$1" ] && echo "Set \"$1\" does not exist" && return;
ln -f "$SETS/$1" "$CONFIG/bg-saved.cfg"
nitrogen --restore
}
function current {
inode=$(stat -c "%i" "$CONFIG/bg-saved.cfg")
basename $(find $SETS -inum $inode)
}
function list {
ls --color=never -1 "$SETS"
}
function new {
cp "$CONFIG/default" "$SETS/$1"
setWallpaper $1
}
function usage {
echo "$(basename $0) -l -c -n -h [SET]"
}
while getopts ":lchn:" opt; do
case $opt in
l)
list
exit
;;
c)
current
exit
;;
n)
new $OPTARG
exit
;;
h | \?)
usage
exit
;;
esac
done
name=${@:$OPTIND:1}
if [[ ! -z "$name" ]]; then
setWallpaper ${@:$OPTIND:1}
else
current
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment