X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Fwallpaper_fav;h=1a73af7ebfae6eee3040ce8bbbac416305d2ddf4;hb=fdc8785261d04be8df8158cf1eef192bf2d000e7;hp=702cd9fdc231f913d0011a6d0e748759ae8da0b2;hpb=101c2c385239d4de389357403085627e06fa7850;p=khome.git diff --git a/home/bin/wallpaper_fav b/home/bin/wallpaper_fav index 702cd9f..1a73af7 100755 --- a/home/bin/wallpaper_fav +++ b/home/bin/wallpaper_fav @@ -2,5 +2,33 @@ set -e -awk 'NR == 2 {sub("^" $1 " +" $2 " +" $3 " +", ""); print}' ~/.fehbg | xargs sha256sum >> "$FILE_WALLPAPER_FAVS" +case "$1" in + '') + current_wallpaper_file=$( + awk ' + NR == 2 { + if (NF > 3) { + # XXX Assume feh wrote a N>4-field command line, like: + # feh --no-fehbg --bg-scale $file + sub("^" $1 " +" $2 " +" $3 " +", "") + } else if (NF < 4) { + # XXX Assume feh wrote a N<4-field command line, like: + # feh --bg-scale $file + sub("^" $1 " +" $2 " +", "") + } else { + printf "[error] Unexpected number of fields in ~/.fehbg command: %s\n" $0 > "/dev/stderr" + exit 1 + } + print + exit 0 + } + ' \ + ~/.fehbg \ + | xargs # Unquote the filename, which feh puts in single quotes. + );; + *) + current_wallpaper_file="$1" +esac + +sha256sum "$current_wallpaper_file" >> "$FILE_WALLPAPER_FAVS" sort -u "$FILE_WALLPAPER_FAVS" | sponge "$FILE_WALLPAPER_FAVS"