new script: qrread
This commit is contained in:
parent
c86e99d073
commit
9816ddd536
51
misc/qrread
Executable file
51
misc/qrread
Executable 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
|
Loading…
Reference in a new issue