52 lines
857 B
Plaintext
52 lines
857 B
Plaintext
![]() |
#!/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
|