diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2019-03-10 21:08:21 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2019-03-10 21:08:21 +0100 |
commit | 7271354955d686d5ea7e698542f7afb4864746ee (patch) | |
tree | ef6962756abd95169058ec61dc10fa43e01293cc | |
parent | e58508dfd01dd02b12b148de0dd90e11b25efe2b (diff) | |
download | scripts-7271354955d686d5ea7e698542f7afb4864746ee.tar.gz scripts-7271354955d686d5ea7e698542f7afb4864746ee.zip |
Created script to manipulate X selections.
-rwxr-xr-x | clipboardUtils.sh | 39 | ||||
-rwxr-xr-x | notification.sh | 3 |
2 files changed, 39 insertions, 3 deletions
diff --git a/clipboardUtils.sh b/clipboardUtils.sh new file mode 100755 index 0000000..8504ef8 --- /dev/null +++ b/clipboardUtils.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# 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 ~")" +[ "$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" = "" ] && 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" = "" ] && exit 0 + case "$toSelection" in + "Clipboard") toOption=b ;; + "Primary") toOption=p ;; + "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?")" + textToWrite="$(dmenu -p "Text to write to $selectedSelection:")" + [ "$textToWrite" = "" ] && exit 0 + case "$selectedSelection" in + "Clipboard") echo "$textToWrite" | xsel -bi ;; + "Primary") echo "$textToWrite" | xsel -pi ;; + "Secondary") echo "$textToWrite" | xsel -si ;; + esac + notify-send "Written [$textToWrite] to $selectedSelection." ;; +esac diff --git a/notification.sh b/notification.sh deleted file mode 100755 index 99ad0f4..0000000 --- a/notification.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -chosen=myselection -pgrep -x dunst && notify-send "$chosen mynotif." |