screenshot: the glaggle fixes

This commit is contained in:
yosh 2024-01-19 16:28:46 -05:00
parent 3ced9c9fbc
commit 8563ac7049
1 changed files with 33 additions and 6 deletions

View File

@ -12,20 +12,35 @@ clean() {
}
save() {
case "${1##*(}" in
png) oxipng -o max "$tmpfp" && mv "$tmpfp" "$OUTFILE.png" ;;
jxl) cjxl "$tmpfp" -d 0.0 "$OUTFILE.jxl" ;;
case "$1" in
*png*) oxipng -o max "$tmpfp" && mv "$tmpfp" "$OUTFILE.png" ;;
*jxl*) cjxl "$tmpfp" -d 0.0 "$OUTFILE.jxl" ;;
*) exit 0 ;;
esac
notify-send -u low "$OUTFILE"
exit 0
}
upload() {
case "$1" in
litterbox*)
time="${1##* }"
url=$(curl -F "reqtype=fileupload" -F "time=$time" -F "fileToUpload=@$tmpfp" 'https://litterbox.catbox.moe/resources/internals/api.php')
;;
owo) url=$(owo -u "$tmpfp") ;;
*) return ;;
esac
[ -n "$url" ] && notify-send -u low "$url" && $clip_cmd <<-EOF
$url
EOF
[ $? -ne 0 ] && notify-send -u low "ERROR! Not uploaded or something ! uh oh"
}
choose() {
while true; do
c="$(printf "save (jxl)\nsave (png)\nedit\nupload\nscan" | $MENU)"
c="$(printf 'save (jxl)\nsave (png)\npreview\nedit\nupload\nscan' | $MENU)"
case "$c" in
save*) save "${c%)}" ;;
save*) save "$c" ;;
edit) eval "$editor"' "$tmpfp"' ;;
scan)
zdata="$(zbarimg -1 "$tmpfp")" || zdata="error: scan failed with exit code $?"
@ -33,7 +48,15 @@ choose() {
$TERMINAL -e sh -c 'printf "%s\n" "${zdata#*:}" | less' &
printf '%s\n' "${zdata#*:}"
;;
*) break ;;
upload)
set +e
upload "$(printf 'owo\nlitterbox 1h\nlitterbox 12h\nlitterbox 24h\nlitterbox 72h\n' | $MENU)"
set -e
;;
preview)
"$image_viewer" "$tmpfp" &
;;
*) break ;;
esac
done
}
@ -52,7 +75,9 @@ case "${XDG_SESSION_TYPE:-}" in
wayland)
editor='swappy -o "$tmpfp" -f'
freeze_img="swayimg -g 0,0,1920,1080"
image_viewer="nsxiv"
freeze_cmd="grim -l 0"
clip_cmd="wl-copy"
ss() {
if [ -n "$REGION" ]; then
reg="$(slurp -f '%x,%y %wx%h')" || return 1
@ -64,7 +89,9 @@ case "${XDG_SESSION_TYPE:-}" in
*)
editor='gimp -n'
freeze_img="nsxiv -b -N SCREENSHOT_FREEZE"
image_viewer="nsxiv"
freeze_cmd="shotgun"
clip_cmd="xclip -sel clipboard"
ss() {
if [ -n "$REGION" ]; then
reg="$(hacksaw -f '-i %i -g %g')" || return 1