4 PIDFILE
=${PIDFILE:-/tmp/wallpaper.pid}
7 trap "rm -f $PIDFILE" SIGTERM
9 WP_SETTER
="/usr/bin/feh"
10 QARMA
="/usr/bin/qarma"
14 $WP_SETTER --bg-fill $NEW_WP
17 # set background function (requires input)
20 # We have a single file as input
23 elif [[ -d $1 ]]; then
26 BGIMG
=$
(find $1 -type f
-print | shuf
-n1)
33 function file_or_dir
() {
34 if [[ -f /tmp
/choice
]]; then
38 FOD
=$
($QARMA --list --text="single image or directory?" --hide-header "file" "directory" > /tmp
/choice
)
41 file_chooser $
(cat /tmp
/choice
)
44 $QARMA --info --title="Exiting!" --text="No wallpaper was changed."
47 $QARMA --error --title="Ooops!!" --text="Something unexpected happened."
52 function file_chooser
() {
55 FILE
="$($QARMA --file-selection --title='Choose your Wallpaper')"
61 $QARMA --info --title="Exiting!" --text="No wallpaper was changed."
64 $QARMA --error --title="Ooops!!" --text="Something unexpected happened."
68 FILE
="$($QARMA --file-selection --directory --title='Choose your Wallpaper directory')"
74 $QARMA --info --title="Exiting!" --text="No wallpaper was changed."
77 $QARMA --error --title="Ooops!!" --text="Something unexpected happened."
81 $QARMA --error --title="Ooops!!" --text="Something unexpected happened."
87 if [[ $
(basename $0) == "wallpaper.sh" ]]; then
88 # we were called as wallpaper.sh, so simple wallpaper setter without qarma interaction
90 elif [[ $
(basename $0) == "change_wallpaper.sh" ]]; then
91 # we use qarma to set the wallpaper
92 $QARMA --question --title="Change Wallpaper" --text="Do you want to change the wallpaper?"
98 $QARMA --info --title="Exiting!" --text="No wallpaper was changed."
101 $QARMA --error --title="Ooops!!" --text="Something unexpected happened."
106 if [[ -r $PIDFILE ]]; then
107 # PIDFILE exists, so I guess there's already an instance running
108 # let's kill it and run again
109 kill -s 15 $
(cat $PIDFILE) > /dev
/null
2>&1
110 # should already be deleted by trap, but just to be sure