diff options
author | katherine <shmibs@shmibbles.me> | 2016-02-17 02:23:20 -0700 |
---|---|---|
committer | katherine <shmibs@shmibbles.me> | 2016-02-17 02:23:20 -0700 |
commit | b351865a2b3678708d70c6e088c70ae8f7fd923f (patch) | |
tree | 96ac5e5f0dde4c8743b4cb72d38f81f8bc303037 /.config/sxiv/exec | |
parent | aabdf33d942619dcf576243f1c25706d286e8291 (diff) | |
download | dotfiles-b351865a2b3678708d70c6e088c70ae8f7fd923f.tar.gz |
refactor key handler
Diffstat (limited to '.config/sxiv/exec')
-rwxr-xr-x | .config/sxiv/exec/key-handler | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 43163c3..6668c36 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -1,34 +1,57 @@ #!/bin/zsh +source ~/.config/init/vars + # The key combo argument has the following form: "[C-][M-][S-]KEY", # where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X # keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix. -while read file -do +files=() +while read line; do + files=( "${files[@]}" "$line" ) +done + + +if [[ "${#files[@]}" -eq 1 ]]; then case "$1" in - "y") - echo -n "$file" | xclip -selection clipboard ;; - "C-d") - rm "$file" ;; - "g") - gimp "$file" & ;; + "y") + echo -n "$files" | xclip -selection clipboard + echo -n "$files" | xclip -selection primary + exit + ;; + "r") + dmenu "${dmenu_args[@]}" -q -noinput + exit + ;; + *) ;; + esac +fi + +case "$1" in + "C-d") rm "${files[@]}" ;; + "g") gimp "${files[@]}" & ;; "s") - scp "$file" shmibbles.me:http/tmp/ - basename=$(basename $file) - if [[ $? -ne 0 ]]; then - notify-send "uploading $basename to /tmp/ failed" - else - ssh shmibbles.me "cd http/tmp; chmod o+r '$basename'" - name=$(echo "https://shmibbles.me/tmp/$basename"\ - | sed -e 's/ /%20/g' -e 's/?/%3f/g') - echo $name | tr -d '\n' | xclip -i -selection clipboard - echo $name | tr -d '\n' | xclip -i -selection primary - notify-send "uploaded $basename to /tmp/" - fi + for file in "${files[@]}"; do + scp "$file" shmibbles.me:http/tmp/ + basename=$(basename $file) + if [[ $? -ne 0 ]]; then + notify-send "uploading $basename to /tmp/ failed" + else + ssh shmibbles.me "cd http/tmp; chmod o+r '$basename'" + name=$(echo "https://shmibbles.me/tmp/$basename"\ + | sed -e 's/ /%20/g' -e 's/?/%3f/g') + echo $name | tr -d '\n' | xclip -i -selection clipboard + echo $name | tr -d '\n' | xclip -i -selection primary + notify-send "uploaded $basename to /tmp/" + fi + done ;; - *) - notify-send "command not recognised" + "n") + for file in "${files[@]}"; do + notify-send "$file" + done + notify-send "${#files[@]}" ;; - esac -done + *) + notify-send "sxiv: command not recognised" ;; +esac |