new script: qrread

This commit is contained in:
Alexander Gehrke 2024-07-16 01:26:00 +02:00
parent c86e99d073
commit 9816ddd536

51
misc/qrread Executable file
View file

@ -0,0 +1,51 @@
#!/bin/zsh
#dep:flameshot zbarimg zenity
code_content=$(flameshot gui --accept-on-select --raw | zbarimg -1 --raw /dev/stdin)
zenity-ask-clip() {
local title="$1"
local text="$2"
shift 2
zenity --question --title "$title" \
--text="$text" \
--switch \
"$@" \
--extra-button "Copy to clipboard" \
--extra-button "Close"
}
handle-link() {
case $(zenity-ask-clip "Link detected" "$1" --extra-button "Open in browser") in
"Open in browser")
xdg-open $1
;;
"Copy to clipboard")
xclip -selection clipboard -i <(echo $1)
;;
*)
exit 0
;;
esac
}
handle-other() {
case $(zenity-ask-clip "Code contents" "$1") in
"Copy to clipboard")
xclip -selection clipboard -i <(echo $1)
;;
*)
exit 0
;;
esac
}
case $code_content in
http*)
handle-link $code_content
;;
*)
handle-other $code_content
;;
esac