swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

key-handler (2032B)


      1 #!/bin/sh
      2 file=$1
      3   [ -z "$selection" ] && selection=$(printf "w - Set as wallpaper\nc - Copy to dir\nm - Move to dir\nr - Rotate 90°\nR - Rotate -90°\nf - Flip horizontal\ny - Copy filename to clipboard\nY - Copy full path to clipboard\nd - Delete\ng - Open in GIMP\ni - Show media info" |
      4     mew -i -l 12 -p "Choose action for selected files:")
      5   action=$(printf "%s" "$selection" | cut -d'-' -f1 | tr -d ' ')
      6   case "$action" in
      7     "w") setbg "$file" & ;;
      8     "c")
      9       [ -z "$destdir" ] && destdir="$(sed "s/#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | mew -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")"
     10       [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
     11       cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
     12       ;;
     13     "m")
     14       [ -z "$destdir" ] && destdir="$(sed "s/#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | mew -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")"
     15       [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit
     16       mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
     17       ;;
     18     "r")
     19       magick "$file" -rotate 90 "$file" ;;
     20     "R")
     21       magick "$file" -rotate -90 "$file" ;;
     22     "f")
     23       magick "$file" -flop "$file" ;;
     24     "y")
     25       printf "%s" "$file" | tr -d '\n' | wl-copy &&
     26         notify-send "$file copied to clipboard" & ;;
     27     "Y")
     28       readlink -f "$file" | tr -d '\n' | wl-copy &&
     29         notify-send "$(readlink -f "$file") copied to clipboard" & ;;
     30     "d")
     31       [ "$(printf "No\\nYes" | mew -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted." ;;
     32     "g")	ifinstalled gimp && setsid -f gimp "$file" ;;
     33     "i")	notify-send "File information" "$(mediainfo "$file" | sed "s/[ ]\+:/:/g;s/: /: <b>/;s/$/<\/b>/" | rg "<b>")" ;;
     34     *) notify-send "No keybind for that key" ;;
     35   esac