summaryrefslogtreecommitdiff
path: root/home/.selfconfigs/imv/imv-ctl
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-04-14 06:38:49 +0200
committerBotond Hende <nettingman@gmail.com>2024-04-14 06:38:49 +0200
commit0221492f62bcc1b766c2a4d5dbe26f6ff2ed8bc2 (patch)
treef91b7ada571a4dab7ae99c8f3ee252616baff2db /home/.selfconfigs/imv/imv-ctl
squashed init
Diffstat (limited to 'home/.selfconfigs/imv/imv-ctl')
-rwxr-xr-xhome/.selfconfigs/imv/imv-ctl65
1 files changed, 65 insertions, 0 deletions
diff --git a/home/.selfconfigs/imv/imv-ctl b/home/.selfconfigs/imv/imv-ctl
new file mode 100755
index 0000000..a55e5e8
--- /dev/null
+++ b/home/.selfconfigs/imv/imv-ctl
@@ -0,0 +1,65 @@
+#!/bin/bash -eu
+
+if [ $# == 0 ] || ! [[ "$1" =~ ^[0-9]+$ ]]; then
+ echo usage: imv-ctl [IMV PID]
+ exit
+fi
+
+trap 'tput sgr0; tput cnorm; tput rmcup || clear; exit 0' SIGINT
+
+tput smcup; tput civis
+tput clear
+
+cat << EOF
+Current pid: $1
+----------------------
+Controls:
+p - quit
+left - previous image
+right - next image
+f - toggle fullscreen
+i - zoom in
+k - zoom out
+l/j - increase/decrease zoom speed
+w/a/s/d - pan
+q/e - increase/decrease pan speed
+u - reset zoom and pan speed
+o - toggle scale modes
+
+current zoom speed: 1
+current pan speed: 10
+EOF
+
+escape_char=$(printf "\u1b")
+zoom_speed=1
+pan_speed=10
+help_lenght=15
+while true; do
+ read -rsn1 mode # get 1 character
+ if [[ $mode == $escape_char ]]; then
+ read -rsn2 mode # read 2 more chars
+ fi
+ case $mode in
+ 'p') echo Quitting... ; tput sgr0; tput cnorm; tput rmcup || clear; exit 0 ;;
+ #'[A') echo UP ;;
+ #'[B') echo DN ;;
+ '[D') imv-msg "$1" p ;;
+ '[C') imv-msg "$1" n ;;
+ 'f') imv-msg "$1" fullscreen ;;
+ 'i') imv-msg "$1" zoom "$zoom_speed" ;;
+ 'k') imv-msg "$1" zoom "-$zoom_speed" ;;
+ 'l') zoom_speed=$((zoom_speed+1)) ; tput sc ; tput cup "$help_lenght" 20 ; echo "$zoom_speed " ; tput sc ;;
+ 'j') zoom_speed=$((zoom_speed-1)) ; if [ "$zoom_speed" -lt 0 ] ; then zoom_speed=0 ; fi ; tput sc ; tput cup "$help_lenght" 20 ; echo "$zoom_speed " ; tput sc ;;
+ 'd') imv-msg "$1" pan "$pan_speed" 0 ;;
+ 'a') imv-msg "$1" pan "-$pan_speed" 0 ;;
+ 's') imv-msg "$1" pan 0 "$pan_speed" ;;
+ 'w') imv-msg "$1" pan 0 "-$pan_speed" ;;
+ 'e') pan_speed=$((pan_speed+5)) ; tput sc ; tput cup $(($help_lenght+1)) 19 ; echo "$pan_speed " ; tput sc ;;
+ 'q') pan_speed=$((pan_speed-5)) ; if [ "$pan_speed" -lt 0 ] ; then pan_speed=0 ; fi ; tput sc ; tput cup $(($help_lenght+1)) 19 ; echo "$pan_speed " ; tput sc ;;
+ 'u') zoom_speed=1 ; pan_speed=10 ; tput sc ; tput cup "$help_lenght" 20 ; echo "$zoom_speed " ; tput sc ;;
+ 'o') imv-msg "$1" scaling next ;;
+
+
+ *) continue ;;
+ esac
+done