1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

scripts/rofi-emoji: simplify clipboard/typing logic

Always do both, because that is the easiest thing to do
This commit is contained in:
Joe Groocock 2020-04-02 13:19:23 +01:00
parent f67a8e5f80
commit d407512522

16
scripts/rofi-emoji Executable file → Normal file
View File

@ -63,11 +63,6 @@ function download() {
notify "$(basename "$0")" "We're all set!" notify "$(basename "$0")" "We're all set!"
} }
function toclip() {
xclip -i -selection primary
xclip -o -selection primary | xclip -i -selection clipboard
}
function repeat() { function repeat() {
local rplc str="$1" count="$2" local rplc str="$1" count="$2"
rplc="$(printf "%${count}s")" rplc="$(printf "%${count}s")"
@ -85,7 +80,6 @@ function display() {
update="⏫ Update emoji cache" update="⏫ Update emoji cache"
emoji=$(printf "$emoji\n$update") emoji=$(printf "$emoji\n$update")
line=$(echo "$emoji" | rofi -dmenu -i -p emoji -normal-window -kb-custom-1 Ctrl+c -kb-row-tab '' -kb-row-select Tab $@) line=$(echo "$emoji" | rofi -dmenu -i -p emoji -normal-window -kb-custom-1 Ctrl+c -kb-row-tab '' -kb-row-select Tab $@)
exit_code=$?
if [ "${line[@]}" == "$update" ]; then if [ "${line[@]}" == "$update" ]; then
download download
@ -100,12 +94,10 @@ function display() {
echo "$quantifier" | egrep -q '^[0-9]+$' || quantifier=1 echo "$quantifier" | egrep -q '^[0-9]+$' || quantifier=1
emojis="$(repeat "${line[0]}" "$quantifier")" emojis="$(repeat "${line[0]}" "$quantifier")"
if [ $exit_code == 0 ]; then sleep 0.1
xdotool type --clearmodifiers "$emojis" # Type the emojis, and put them in the clipboard
echo -n "$emojis" | xclip -i xdotool type --clearmodifiers "$emojis"
elif [ $exit_code == 10 ]; then printf "%s" "$emojis" | xclip -i -selection CLIPBOARD
echo -n "$emojis" | xclip -i
fi
} }