From 1a7aabb2da0fb0b65718ff08edcfc1037380d781 Mon Sep 17 00:00:00 2001 From: Jonas Strassel Date: Sat, 23 Oct 2021 19:45:46 +0200 Subject: [PATCH] feat(waybar): cliphist only if installed (#76) * feat(waybar): cliphist only if installed * feat: purge cliphist before shutdown * fix: safer check for command * feat: signallify wl-paste watch * fix: remove disfunct shutdown removal * chore: move purge to middle click * feat: purge on reboot and shutdown and logout * feat: introduce variable to purge cliphist on logout --- .../etc/sway/config.d/99-autostart-applications.conf | 1 + community/sway/etc/sway/modes/shutdown | 8 +++++--- .../sway/usr/share/sway/templates/waybar/config.jsonc | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/community/sway/etc/sway/config.d/99-autostart-applications.conf b/community/sway/etc/sway/config.d/99-autostart-applications.conf index d1aaf047f..f083d084d 100644 --- a/community/sway/etc/sway/config.d/99-autostart-applications.conf +++ b/community/sway/etc/sway/config.d/99-autostart-applications.conf @@ -14,6 +14,7 @@ exec { '[ -x "$(command -v foot)" ] && /usr/share/sway/scripts/foot.sh --server' '[ -x "$(command -v nwg-wrapper)" ] && [ -f $HOME/.config/nwg-wrapper/help.sh ] && /usr/share/sway/scripts/help.sh --restore' '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch cliphist store' + '[ -x "$(command -v wl-paste)" ] && [ -x "$(command -v cliphist)" ] && wl-paste --watch pkill -RTMIN+9 waybar' } exec_always { '[ -x "$(command -v spice-vdagent)" ] && spice-vdagent' diff --git a/community/sway/etc/sway/modes/shutdown b/community/sway/etc/sway/modes/shutdown index 718a1769c..e2c5c9bcc 100644 --- a/community/sway/etc/sway/modes/shutdown +++ b/community/sway/etc/sway/modes/shutdown @@ -9,12 +9,14 @@ set $mode_shutdown "\ (s)shutdown \ " +set $purge_cliphist [ $purge_cliphist_logout == 'true' ] && rm -f $HOME/.cache/cliphist/db || exit 0 + mode --pango_markup $mode_shutdown { # lock $bindsym l mode "default", exec $locking # logout - $bindsym e exec loginctl terminate-user $USER + $bindsym e exec $purge_cliphist; exec loginctl terminate-user $USER # suspend $bindsym u mode "default", exec systemctl suspend @@ -23,10 +25,10 @@ mode --pango_markup $mode_shutdown { $bindsym h mode "default", exec systemctl hibernate # shutdown - $bindsym s exec systemctl poweroff + $bindsym s exec $purge_cliphist; exec systemctl poweroff # reboot - $bindsym r exec systemctl reboot + $bindsym r exec $purge_cliphist; exec systemctl reboot # Return to default mode. $bindsym Escape mode "default" diff --git a/community/sway/usr/share/sway/templates/waybar/config.jsonc b/community/sway/usr/share/sway/templates/waybar/config.jsonc index 8a1805083..87070ad35 100644 --- a/community/sway/usr/share/sway/templates/waybar/config.jsonc +++ b/community/sway/usr/share/sway/templates/waybar/config.jsonc @@ -236,7 +236,7 @@ "return-type": "json", "format" : " {}", "exec": "gh api '/notifications' -q '{ text: length }' | cat -", - "exec-if": "command -v gh >/dev/null && gh auth status 2>&1 | grep -q -m 1 'Logged in' && gh api '/notifications' -q 'length' | grep -q -m 1 '0' ; test $? -eq 1", + "exec-if": "[ -x \"$(command -v gh)\" ] && gh auth status 2>&1 | grep -q -m 1 'Logged in' && gh api '/notifications' -q 'length' | grep -q -m 1 '0' ; test $? -eq 1", "on-click": "xdg-open https://github.com/notifications && sleep 30 && pkill -RTMIN+4 waybar", "signal": 4 }, @@ -259,10 +259,13 @@ }, "custom/clipboard": { "format": "", + "interval": "once", "return-type": "json", - "on-click": "swaymsg -q exec '$clipboard'", + "on-click": "swaymsg -q exec '$clipboard'; pkill -RTMIN+9 waybar", + "on-click-middle": "rm -f ~/.cache/cliphist/db; pkill -RTMIN+9 waybar", "exec": "printf '{\"tooltip\":\"%s\"}' $(cliphist list | wc -l)", - "exec-if": "[ $(cliphist list | wc -l) -gt 0 ]" + "exec-if": "[ -x \"$(command -v cliphist)\" ] && [ $(cliphist list | wc -l) -gt 0 ]", + "signal": 9 }, "custom/weather": { "icon-size": 42,