aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_clip-picker.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/waybar/executable_clip-picker.sh')
-rw-r--r--dot_config/waybar/executable_clip-picker.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/dot_config/waybar/executable_clip-picker.sh b/dot_config/waybar/executable_clip-picker.sh
new file mode 100644
index 0000000..11ebf4c
--- /dev/null
+++ b/dot_config/waybar/executable_clip-picker.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Clipboard picker on top of cliphist + wofi (vim-nav, hide-search,
+# Alt-d to delete the highlighted entry).
+#
+# Modes:
+# pick Enter pastes (cliphist decode | wl-copy)
+# delete Enter deletes (cliphist delete)
+#
+# Alt-d in pick mode deletes the highlighted entry without pasting.
+
+set -u
+
+mode=${1:-pick}
+style=$HOME/.config/wofi/style.css
+
+set +e
+selection=$(
+ cliphist list \
+ | wofi --dmenu --hide-search --prompt Clip \
+ --define key_custom_0=Alt-d \
+ ${style:+--style "$style"}
+)
+rc=$?
+set -e
+
+[ -z "$selection" ] && exit 0
+
+case "$mode:$rc" in
+ pick:0) printf '%s' "$selection" | cliphist decode | wl-copy ;;
+ pick:10) printf '%s' "$selection" | cliphist delete ;;
+ delete:0|delete:10) printf '%s' "$selection" | cliphist delete ;;
+esac