Skip to content

Commit

Permalink
feat(waybar): cliphist only if installed (#76)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
boredland committed Aug 11, 2022
1 parent ec32883 commit 1a7aabb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 5 additions & 3 deletions community/sway/etc/sway/modes/shutdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ set $mode_shutdown "\
<span foreground='$color10'>(<b>s</b>)</span>shutdown \
</span>"

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
Expand All @@ -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"
Expand Down
9 changes: 6 additions & 3 deletions community/sway/usr/share/sway/templates/waybar/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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,
Expand Down

0 comments on commit 1a7aabb

Please sign in to comment.