diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2024-07-29 18:33:56 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2024-07-29 18:33:56 +0400 |
commit | b70ddbcf178e63c91c1e4340a67b2e1dfe56156f (patch) | |
tree | 38142a6ffaa65abafa5294dfe719042ef32f0626 | |
parent | f0e3792e334675e2bc00bd177ec208312dee25b6 (diff) |
sxiv: config style updated
l---------[-rwxr-xr-x] | config/nsxiv/exec/key-handler | 44 | ||||
-rwxr-xr-x | config/sxiv/exec/key-handler | 74 |
2 files changed, 75 insertions, 43 deletions
diff --git a/config/nsxiv/exec/key-handler b/config/nsxiv/exec/key-handler index a3880e4..c360d6b 100755..120000 --- a/config/nsxiv/exec/key-handler +++ b/config/nsxiv/exec/key-handler @@ -1,43 +1 @@ -#!/bin/sh - -# For theme to be applied ~/.Xresource file must be present - -while read -r file -do - case "$1" in - - "m") - [ -z $destdir ] && destdir="$(echo "$HOME/Pictures" | dmenu -p "Move directory: " | sed "s|~|$HOME|g")" - - [ ! -d $destdir ] && { nsend "Not a directory" ; exit 2 ;} - - mv "$file" "$destdir" && nsend "$file moved to $destdir" & - ;; - - "c") - - [ -z $destdir ] && destdir="$(echo "$HOME/Pictures" | dmenu -p "Copy directory: " | sed "s|~|$HOME|g")" - - [ ! -d $destdir ] && { nsend "Not a directory" ; exit 2 ;} - - cp "$file" "$destdir" && nsend "$file copied to $destdir" & - ;; - - "w") - setwp "$file" && nsend "Wallpaper changed to $file" ;; - "d") - [ ! -d ~/.trash ] && { mkdir ~/.trash && nsend "~/.trash created";} - mv "$file" ~/.trash && nsend "$file is moved to ~/.trash" ;; - "r") - convert -rotate 90 "$file" "$file" ;; - "R") - convert -rotate -90 "$file" "$file" ;; - "f") - convert -flop "$file" "$file" ;; - "y") - echo -n "$file" | xclip -selection clipboard && nsend "Copied to clipboard" & ;; - "Y") - readlink -f "$file" | tr -d '\n' | xclip -selection clipboard && nsend "Copied to clipboard" & ;; - - esac - done +../../sxiv/exec/key-handler
\ No newline at end of file diff --git a/config/sxiv/exec/key-handler b/config/sxiv/exec/key-handler new file mode 100755 index 0000000..01d2c41 --- /dev/null +++ b/config/sxiv/exec/key-handler @@ -0,0 +1,74 @@ +#!/bin/sh + +# For theme to be applied ~/.Xresource file must be present +picdir="${HOME}/pics" + +while read -r file; do + case "$1" in + "m") + if [ -z "${destdir}" ]; then + destdir="$(echo "${picdir}" \ + | dmenu -p "Move directory: " \ + | sed "s|~|${HOME}|g")" + fi + + if [ ! -d "${destdir}" ]; then + nsend "Not a directory" + exit 1 + fi + + if mv "${file}" "${destdir}"; then + nsend "${file} moved to ${destdir}" & + else + nsend "Failed to move ${file} to ${destdir}" + fi + ;; + "c") + + if [ -z "${destdir}" ];then + destdir="$(echo "${picdir}" \ + | dmenu -p "Copy directory: " \ + | sed "s|~|${HOME}|g")" + fi + + if [ ! -d "${destdir}" ]; then + nsend "Not a directory" & + exit 1 + fi + + if cp "${file}" "${destdir}"; then + nsend "${file} copied to ${destdir}" & + else + nsend "Failed to copy ${file} to ${destdir}" & + fi + ;; + "w") swall "$file" ;; + + "d") + mkdir -p ~/.trash + + if mv "$file" ~/.trash; then + nsend "$file is moved to ~/.trash" & + else + nsend "Failed to move ${file} to ~/.trash" & + fi + ;; + "r") convert -rotate 90 "$file" "$file" ;; + "R") convert -rotate -90 "$file" "$file" ;; + "f") convert -flop "$file" "$file" ;; + "y") + if printf "%s" "${file}" | xclip -selection clipboard; then + nsend "Copied to clipboard" & + else + nsend "Failed to copy to clipboard" & + fi + ;; + "Y") + if readlink -f "$file" | tr -d '\n' | xclip -selection clipboard; then + nsend "Copied to clipboard" & + else + nsend "Failed to copy to clipboard" & + fi + ;; + esac +done |