From 8684189cedecb616e40e2546c1d2b1c3f1bc6e09 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Sun, 30 Jun 2019 19:21:26 +0200 Subject: Added better wallpaper switch handling --- smart-wallpaper | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/smart-wallpaper b/smart-wallpaper index 53f729b..e9a0fe5 100755 --- a/smart-wallpaper +++ b/smart-wallpaper @@ -2,6 +2,8 @@ trap cleanup EXIT +period=500 + input_daytimewallpaper='' input_nighttimewallpaper='' daytimewallpaper='' @@ -10,10 +12,11 @@ location='' currenttime='pn5Lf1f8SH' #random string so the first loop works timebool=false +procid='' cleanup() { - if [[ $(pidof gifview | wc -l) == 1 ]]; then - kill $(pidof gifview) + if [[ $procid != '' ]]; then + kill $procid fi } @@ -28,14 +31,16 @@ print_usage() { set_wallpaper() { - if [[ $(pidof gifview | wc -l) == 1 ]]; then - kill $(pidof gifview) + if [[ $procid != '' ]]; then + kill $procid fi if [[ $1 == *".gif" ]] && [ -f /usr/bin/gifview ]; then gifview --animate -w root $1 & + procid=$! else feh --bg-fill $1 + procid='' fi } @@ -113,5 +118,5 @@ do fi fi - sleep 500s + sleep $period done -- cgit 1.4.1