From 0221492f62bcc1b766c2a4d5dbe26f6ff2ed8bc2 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Sun, 14 Apr 2024 06:38:49 +0200 Subject: squashed init --- home/.selfconfigs/imv/imv-ctl | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 home/.selfconfigs/imv/imv-ctl (limited to 'home/.selfconfigs/imv') 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 -- cgit v1.2.3-70-g09d2