dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit c12f62667292c358bc3c1d356ba14259b59782f1
parent d122fc610bcec7f2e5124cafa424a42a3356022d
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 10 May 2019 09:50:53 -0700

Improve syntax of sxiv utility script

Diffstat:
M.config/sxiv/exec/key-handler | 81++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 49 insertions(+), 32 deletions(-)

diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler @@ -1,37 +1,54 @@ #!/bin/sh -while read -r file -do - fullpath="$(pwd)/$file" - case "$1" in +set -e +while read -r file; do + fullpath="$(pwd)/$file" + case "$1" in "w") - cp "$file" ~/.config/wall.png && - feh --bg-scale "$HOME/.config/wall.png" - notify-send -i "$HOME/.config/wall.png" "Wallpaper changed." ;; + cp "$file" ~/.config/wall.png + feh --bg-scale "$HOME/.config/wall.png" + notify-send -i "$HOME/.config/wall.png" "Wallpaper changed." + ;; "c") - [ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.bmdirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")" - [ -z "$destdir" ] && exit - cp "$file" "$destdir" && notify-send -i "$fullpath" "$file copied to $destdir." & - ;; + [ -z "$destdir" ] && \ + destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.bmdirs | \ + awk '{print $2}' | \ + dmenu -l 20 -i -p "Copy file(s) to where?" | \ + sed "s|~|$HOME|g")" + [ -z "$destdir" ] && exit + cp "$file" "$destdir" + notify-send -i "$fullpath" "$file copied to $destdir." & + ;; "m") - [ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.bmdirs | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")" - [ -z "$destdir" ] && exit - cp "$file" "$destdir" && notify-send -i "$fullpath" "$file moved to $destdir." & - ;; - "r") - convert -rotate 90 "$file" "$file" ;; - "R") - convert -rotate -90 "$file" "$file" ;; - "f") - convert -flop "$file" "$file" ;; - "y") - printf "%s" "$file" | xclip -selection clipboard && - notify-send "$file copied to clipboard" & ;; - "Y") - printf "%s" "$fullpath" | xclip -selection clipboard && - notify-send "$fullpath copied to clipboard" & ;; - "d") - [ "$(printf "No\\nYes" | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted." ;; - "G") - gimp "$file" & ;; - esac + [ -z "$destdir" ] && \ + destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ~/.bmdirs | \ + awk '{print $2}' | \ + dmenu -l 20 -i -p "Move file(s) to where?" | \ + sed "s|~|$HOME|g")" + [ -z "$destdir" ] && exit + cp "$file" "$destdir" + notify-send -i "$fullpath" "$file moved to $destdir." & + ;; + "r") + convert -rotate 90 "$file" "$file" + ;; + "R") + convert -rotate -90 "$file" "$file" + ;; + "f") + convert -flop "$file" "$file" + ;; + "y") + printf "%s" "$file" | xclip -selection clipboard + notify-send "$file copied to clipboard" & ;; + "Y") + printf "%s" "$fullpath" | xclip -selection clipboard + notify-send "$fullpath copied to clipboard" & ;; + "d") + [ "$(printf "No\\nYes" | \ + dmenu -i -p "Really delete $file?")" = "Yes" ] && \ + rm "$file" && notify-send "$file deleted." ;; + "G") + gimp "$file" & + ;; + esac done