voidrice/.config/sxiv/exec/key-handler
vlad doster eed099b954 Cohesive shell script formatting
- Format all shell scripts using [shfmt]
  (https://github.com/mvdan/sh).

Options used:

* `-bn`: binary ops like && and | may start a line
* `-sr`: redirect operators will be followed by a space
* `-ci`: indent switch cases
* `-i 4`: indent 4 spaces
* `-s`: simplify the code
* `-p`: parse for posix compliance

- Add Github action to lint changes to scripts and enforce formatting
  going forward

Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
2021-03-15 06:16:20 -05:00

39 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
while read file; do
case "$1" in
"w") setbg "$file" & ;;
"c")
[ -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")"
[ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
;;
"m")
[ -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")"
[ ! -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")
echo -n "$file" | tr -d '\n' | xclip -selection clipboard \
&& notify-send "$file copied to clipboard" &
;;
"Y")
readlink -f "$file" | tr -d '\n' | xclip -selection clipboard \
&& 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."
;;
"g") ifinstalled gimp && setsid -f gimp "$file" ;;
"i") notify-send "File information" "$(mediainfo "$file")" ;;
esac
done