aboutsummaryrefslogtreecommitdiff
path: root/clipboardUtils.sh
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-07-31 11:54:40 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-07-31 11:54:40 +0200
commitf832d43206035e4101472a1d07d261952dfdd85d (patch)
treed2d3d5b0bb58e45c1e21912d08f266f0870a270b /clipboardUtils.sh
parentb17f7c8d0e626b976f9888f0d7f1d57c86f05773 (diff)
downloadscripts-f832d43206035e4101472a1d07d261952dfdd85d.tar.gz
scripts-f832d43206035e4101472a1d07d261952dfdd85d.zip
Swapped echo -e for printf in various scripts.
Diffstat (limited to 'clipboardUtils.sh')
-rwxr-xr-xclipboardUtils.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/clipboardUtils.sh b/clipboardUtils.sh
index fadb3e7..49f39d0 100755
--- a/clipboardUtils.sh
+++ b/clipboardUtils.sh
@@ -3,22 +3,27 @@
# Manipulate the X selection
# Dependencies: dmenu, xsel
-options="Show selections\nReplicate selections\nWrite to selection"
-target="$(echo -e "$options" | dmenu -l 3 -i -p "~ Clipboard utils ~")"
+options="Show selections\nReplicate selections\nWrite to selection\n"
+selections="Clipboard\nPrimary\nSecondary\n"
+
+target="$(printf "$options" | dmenu -l 3 -i -p "~ Clipboard utils ~")"
[ "$target" = "" ] && exit 0
+
case "$target" in
+
"Show selections") notify-send "Clipboard: [$(xsel -bo)]
Primary: [$(xsel -po)]
Secondary: [$(xsel -so)]" ;;
+
"Replicate selections")
- fromSelection="$(echo -e "Clipboard\nPrimary\nSecondary" | dmenu -l 3 -i -p "From selection:")"
+ fromSelection="$(printf "$selections" | dmenu -l 3 -i -p "From selection:")"
[ "$fromSelection" = "" ] && exit 0
case "$fromSelection" in
"Clipboard") fromOption=b ;;
"Primary") fromOption=p ;;
"Secondary") fromOption=s ;;
esac
- toSelection="$(echo -e "Clipboard\nPrimary\nSecondary" | dmenu -l 3 -i -p "To selection:")"
+ toSelection="$(printf "$selections" | dmenu -l 3 -i -p "To selection:")"
[ "$toSelection" = "" ] && exit 0
case "$toSelection" in
"Clipboard") toOption=b ;;
@@ -26,8 +31,9 @@ Secondary: [$(xsel -so)]" ;;
"Secondary") toOption=s ;;
esac
xsel -"$fromOption"o | xsel -"$toOption"i && notify-send "Copied [$(xsel -"$toOption"o)] from $fromSelection to $toSelection." ;;
+
"Write to selection")
- selectedSelection="$(echo -e "Clipboard\nPrimary\nSecondary" | dmenu -l 3 -i -p "Write to which selection?")"
+ selectedSelection="$(printf "$selections" | dmenu -l 3 -i -p "Write to which selection?")"
textToWrite="$(dmenu -p "Text to write to $selectedSelection:")"
[ "$textToWrite" = "" ] && exit 0
case "$selectedSelection" in
@@ -36,4 +42,5 @@ Secondary: [$(xsel -so)]" ;;
"Secondary") echo "$textToWrite" | xsel -si ;;
esac
notify-send "Written [$textToWrite] to $selectedSelection." ;;
+
esac