dotfiles/.config/nsxiv/exec/key-handler

34 lines
1.5 KiB
Plaintext
Raw Normal View History

2023-10-12 15:12:12 +02:00
#!/bin/sh
while read -r file
2020-07-04 14:23:27 +02:00
do
case "$1" in
"w") setbg "$file" & ;;
"c")
2023-10-12 15:12:12 +02:00
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")"
2020-07-04 14:23:27 +02:00
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
2023-10-12 15:12:12 +02:00
cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
2020-07-04 14:23:27 +02:00
;;
"m")
2023-10-12 15:12:12 +02:00
[ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")"
2020-07-04 14:23:27 +02:00
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
;;
"r")
convert -rotate 90 "$file" "$file" ;;
"R")
convert -rotate -90 "$file" "$file" ;;
"f")
convert -flop "$file" "$file" ;;
"y")
2023-10-12 15:12:12 +02:00
printf "%s" "$file" | tr -d '\n' | xclip -selection clipboard &&
2020-07-04 14:23:27 +02:00
notify-send "$file copied to clipboard" & ;;
"Y")
2023-10-12 15:12:12 +02:00
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard &&
2020-07-04 14:23:27 +02:00
notify-send "$(readlink -f "$file") copied to clipboard" & ;;
"d")
[ "$(printf "No\\nYes" | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted." ;;
2023-10-12 15:12:12 +02:00
"g") ifinstalled gimp && setsid -f gimp "$file" ;;
"i") notify-send "File information" "$(mediainfo "$file")" ;;
2020-07-04 14:23:27 +02:00
esac
done