From: Siraaj Khandkar Date: Sun, 23 Jan 2022 21:52:22 +0000 (-0500) Subject: Support removing from favorites set X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=0e76831b3ccfee00d4ffd0f5cbc3e1ccf978fbcc;p=khome.git Support removing from favorites set --- diff --git a/home/bin/wallpapers_preview b/home/bin/wallpapers_preview index 8727517..c859451 100755 --- a/home/bin/wallpapers_preview +++ b/home/bin/wallpapers_preview @@ -15,7 +15,8 @@ read_command() { q | Q) echo 'CMD_QUIT';; h | H) echo 'CMD_MOVE_BACK';; l | L) echo 'CMD_MOVE_FORWARD';; - f | F) echo 'CMD_FAVORITE';; + f | F) echo 'CMD_FAVORITE_ADD';; + r | R) echo 'CMD_FAVORITE_REMOVE';; *) echo 'CMD_UKNOWN';; esac } @@ -73,8 +74,16 @@ paths_preview() { (( i = i == 0 ? (n - 1) : i - 1));; CMD_MOVE_FORWARD) (( i = (i + 1) % n ));; - CMD_FAVORITE) + CMD_FAVORITE_ADD) + printf 'Adding to favorites set: "%s"\n' "$path" >&2 wallpaper_fav;; + CMD_FAVORITE_REMOVE) + printf 'Removing from favorites set: "%s"\n' "$path" >&2 + digest=$(sha256sum "$path" | awk '{print $1}') + grep -v "$digest" "$FILE_WALLPAPER_FAVS" \ + | sort -u \ + | sponge "$FILE_WALLPAPER_FAVS" + ;; CMD_UKNOWN) continue;; esac