config

OpenBSD system configuration
git clone git://jacobedwards.org/config
Log | Files | Refs | README

commit f14c1d03969ee8a5975dba2f1d4e8de8dfe63a55
parent 30a4e7c7bac82067d7567365f416fb48452be022
Author: Jacob R. Edwards <n/a>
Date:   Mon,  8 Nov 2021 22:49:19 -0800

Update sxiv(1) key handling script

Diffstat:
Mlocal/sxiv/config/sxiv/exec/key-handler | 30++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/local/sxiv/config/sxiv/exec/key-handler b/local/sxiv/config/sxiv/exec/key-handler @@ -1,26 +1,20 @@ #!/bin/sh -e -# Copyright 2020 Jacob R. Edwards +# Copyright 2020, 2021 Jacob R. Edwards # License: GPLv3 # # key-handler -- sxiv(1) key handling script -buf=$(cat) -IFS=' -' +images=__LINES__ -ask() test $(printf 'n\ny\n' | dmenu) = 'y' -err() { printf '%s: ' `basename $0` 1>&2 && printf "$@" 1>&2; exit 1; } -last() eval echo "\$$#" +args() { tr '\n' '\0' | xargs -0J "$images" "$@"; } +ask() test "$(printf 'n\ny\n' | dmenu -p "$1?")" = 'y' +die() { echo "$@" 1>&2; exit 1; } +read() dmenu -p "$1" < /dev/null -case $1 in -(C-w) - setbg "$(last $buf)";; -(C-m) - mv $buf "$(fsmenu . -type d)";; -(C-c) - cp $buf "$(fsmenu . -type d)";; -(C-x) - ask && rm $buf;; -(*) - err '%s: Invalid command.\n' $1; +case "$1" in +(C-c) eval args "$(read command)";; # use $images to access images +(C-m) args mv lines "$(read dir)";; +(C-w) setbg "$(tail -1)";; +(C-x) ask remove && args rm $images;; +(*) die "$1: Invalid command";; esac