aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/plumber-dmenu
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/plumber-dmenu')
-rwxr-xr-x.local/bin/plumber-dmenu20
1 files changed, 12 insertions, 8 deletions
diff --git a/.local/bin/plumber-dmenu b/.local/bin/plumber-dmenu
index f2aa6b6..ea141c2 100755
--- a/.local/bin/plumber-dmenu
+++ b/.local/bin/plumber-dmenu
@@ -1,4 +1,5 @@
#!/bin/sh -eu
+
options="\
case->lower
case->title
@@ -18,11 +19,14 @@ text->urlize
verse->kjv
word->dictionary
"
-printf "%s" "$options" \
- | dmenu -i -b -p ⠀:::⠀plumber⠀::: \
- | while read -r option
- do
- text=$(plumber --option "$option" --text "$(xsel -o)")
- { notify-send "$text" && printf "%s" "$text" | xsel -ib; } \
- || notify-send "Plumber: Clipboard selection is empty"
- done
+
+selection=$(
+ printf "%s" "$options" | dmenu -i -b -p ⠀:::⠀plumber⠀::: ||
+ { [ "$?" = 127 ] && kill -15 "$$" && "$0"; }
+)
+
+printf "%s\n" "$selection" | while read -r option; do
+ text=$(plumber --option "$option" --text "$(xsel -o)")
+ { notify-send "$text" && printf "%s" "$text" | xsel -ib; } ||
+ notify-send "Plumber: Clipboard selection is empty"
+done