summaryrefslogtreecommitdiff
path: root/ar/.config/nsxiv/exec/key-handler
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
commitc80a54e42b52ce297f0f2f71af23c562832025c7 (patch)
treedcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.config/nsxiv/exec/key-handler
init
Diffstat (limited to 'ar/.config/nsxiv/exec/key-handler')
-rwxr-xr-xar/.config/nsxiv/exec/key-handler67
1 files changed, 67 insertions, 0 deletions
diff --git a/ar/.config/nsxiv/exec/key-handler b/ar/.config/nsxiv/exec/key-handler
new file mode 100755
index 0000000..fc48110
--- /dev/null
+++ b/ar/.config/nsxiv/exec/key-handler
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+while read -r file; do
+ case "$1" in
+ "h")
+ notify-send "Macro <C-x> key bindings:" "\- b: Set as wallpaper
+- c: Copy file
+- d: Delete file
+- h: Help key bindings
+- f: Flip file horizontally
+- g: Edit in GIMP
+- i: Show file information
+- m: Move file
+- r: Rotate file 90 degrees
+- R: Rotate file -90 degrees
+- s: Resize file
+- S: Change resolution
+- y: Copy file name to clipboard
+- Y: Copy file path to clipboard" &
+ ;;
+ "b") setbg "$file" & ;;
+ "c")
+ [ -z "$destdir" ] && destdir="$(sed "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." &
+ ;;
+ "d")
+ [ "$(printf "No\\nYes" | dmenu -i -p "Really delete $file?")" = "Yes" ] && rm "$file" && notify-send "$file deleted."
+ ;;
+ "f")
+ magick "$file" -flop "$file"
+ ;;
+ "g") ifinstalled gimp && setsid -f gimp "$file" ;;
+ "i") notify-send "File information" "$(mediainfo "$file" | sed "s/[ ]\+:/:/g;s/: /: <b>/;s/$/<\/b>/" | grep "<b>")" ;;
+ "m")
+ [ -z "$destdir" ] && destdir="$(sed "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")
+ magick "$file" -rotate 90 "$file"
+ ;;
+ "R")
+ magick "$file" -rotate -90 "$file"
+ ;;
+ "s")
+ size="$(echo "" | dmenu -i -p "Enter a size to resize $file ($(identify -format "%wx%h" $file)): ")"
+ magick "$file" -resize "$size" "$file" && notify-send "$file size has changed to $size."
+ ;;
+ "S")
+ resolution="$(printf low\\nmedium\\nhigh | dmenu -i -p "Choose a resolution: ")"
+ case "$resolution" in
+ low) magick "$file" -resample 72 "$file" ;;
+ medium) magick "$file" -resample 150 "$file" ;;
+ high) magick "$file" -resample 300 "$file" ;;
+ esac && notify-send "Changed $file resolution to $resolution."
+ ;;
+ "y")
+ printf "%s" "$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" &
+ ;;
+ esac
+done