screenshot: actual swappy integration

This commit is contained in:
yosh 2023-10-04 17:21:35 -04:00
parent 45b1320a1a
commit 7d37a8300d
1 changed files with 5 additions and 12 deletions

View File

@ -1,6 +1,5 @@
#!/bin/sh
set -euf
set -x
OUTFILE="${HOME}/pics/screenshots/$(date +"%Y-%m-%d_%H-%M-%S")" # output file template, change as needed
# menu + args, split on spaces
@ -24,20 +23,14 @@ save() {
choose() {
while true; do
c="$(printf "save (jxl)\nsave (png)\nedit\nscan" | $MENU)"
c="$(printf "save (jxl)\nsave (png)\nedit\nscan" | $MENU)"
case "$c" in
save*) save "${c%)}" ;;
edit)
h1="$(sha256sum "$tmpfp")"
$editor "$tmpfp"
h2="$(sha256sum "$tmpfp")"
[ "$h1" != "$h2" ] && save # change, save
exit 0
;;
edit) eval "$editor"' "$tmpfp"' ;;
scan)
zdata="$(zbarimg -1 "$tmpfp")" || zdata="error: scan failed with exit code $?"
export zdata
$TERMINAL -e sh -c 'printf "%s\n" "${zdata#*:}"; read -r __' &
$TERMINAL -e sh -c 'printf "%s\n" "${zdata#*:}" | less' &
printf '%s\n' "${zdata#*:}"
;;
*) break ;;
@ -57,7 +50,7 @@ freeze() {
case "${XDG_SESSION_TYPE:-}" in
wayland)
editor="swappy -f"
editor='swappy -o "$tmpfp" -f'
freeze_img="swayimg -g 0,0,1920,1080"
freeze_cmd="grim -l 0"
ss() {
@ -69,7 +62,7 @@ case "${XDG_SESSION_TYPE:-}" in
}
;;
*)
editor="gimp -n"
editor='gimp -n'
freeze_img="nsxiv -b -N SCREENSHOT_FREEZE"
freeze_cmd="shotgun"
ss() {