From ee3167c8a90341dc4d8eb911f72d5430173f3719 Mon Sep 17 00:00:00 2001
From: Gustaf Rydholm <gustaf.rydholm@gmail.com>
Date: Wed, 25 Sep 2024 00:38:58 +0200
Subject: Replace sxiv with nsxiv

---
 .config/nsxiv/exec/key-handler | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 .config/nsxiv/exec/key-handler

(limited to '.config/nsxiv/exec')

diff --git a/.config/nsxiv/exec/key-handler b/.config/nsxiv/exec/key-handler
new file mode 100644
index 0000000..3d9565f
--- /dev/null
+++ b/.config/nsxiv/exec/key-handler
@@ -0,0 +1,33 @@
+#!/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
-- 
cgit v1.2.3-70-g09d2