Created
January 5, 2018 03:48
-
-
Save wdkrnls/b444ef77d450b7b0c24c934bba861760 to your computer and use it in GitHub Desktop.
Set wallpaper independently for each tag in herbstluftwm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This code was modified from Thorsten by me: | |
# https://bbs.archlinux.org/viewtopic.php?pid=1024618#p1024618 | |
# sets a tag defined wallpaper when tag changes | |
declare -A WALLPAPER | |
# These wallpapers come with Deepin desktop environment, but also look great in hlwm | |
DIR=/usr/share/backgrounds | |
WALLPAPER=( | |
# first wallpaper will be the fallback wallpaper | |
[0]=$DIR/Autumn_in_Kanas_by_Wang_Jinyu.jpg | |
[file]=$DIR/Reflection_of_the_Kanas_Lake_by_Wang_Jinyu.jpg | |
[edit]=$DIR/Ocean_by_Shu_Le.jpg | |
[read]=$DIR/Scenery_in_Plateau_by_Arto_Marttinen.jpg | |
[browse]=$DIR/Sunrise_by_Alexandre_Godreau.jpg | |
[draw]=$DIR/Overlooking_of_the_Coastal_by_Alex_Siale.jpg | |
[watch]=$DIR/Maple_Leaf_by_Aaron_Burden.jpg | |
[hear]=$DIR/Dew_by_Aaron_Burden.jpg | |
[mail]=$DIR/Hummingbird_by_Shu_Le.jpg | |
[chat]=$DIR/Sunset_of_the_Lake_Nam_by_Wang_Jinyu.jpg | |
) | |
# it should (hopefully) die on reload | |
herbstclient --idle '(tag_changed|reload)' \ | |
| while read line ; do | |
ARGS=( $line ) | |
HOOK=${ARGS[0]} | |
TAG=${ARGS[1]} | |
case $HOOK in | |
reload) | |
exit 1 | |
;; | |
quit_panel) | |
exit 1 | |
;; | |
tag_changed) | |
if ! [ -z "${WALLPAPER[$TAG]}" ] ; then | |
# there is a wallpaper for this tag | |
CUR=${WALLPAPER[$TAG]} | |
else | |
# there is no wallpaper for this tag -> fall back | |
CUR=${WALLPAPER[0]} | |
fi | |
echo "setting wallpaper to $CUR" | |
feh --bg-scale $CUR | |
;; | |
*) ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment