Skip to content

Commit

Permalink
Add QR code flag to goshy
Browse files Browse the repository at this point in the history
This commit adds an additional flag for displaying an QR code as the
respone of running goshy. It requires the qrencode package.

One could check if the depedency exists, but any OS should be able to
report this themselves. So this bloat was not added.

Sadly `qrencode -t ASCII` was not working for me. It printed a not
scannable QR code. Thus an image is opened.
  • Loading branch information
riotbib committed Mar 27, 2024
1 parent 99f7580 commit 2242d8b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contrib/bash/goshy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Options:
-i --instance Complete URL to the gosh instance.
-p --period TIMEFRAME Set a custom expiry period.
-u --only-url Print only URL as response.
-q --qr-code Print only QR code as response.
EOF
}

Expand Down Expand Up @@ -37,6 +38,10 @@ while :; do
ONLYURL="1"
;;

-q|--qr-code)
QRCODE="1"
;;

*)
FILE=$1
break
Expand Down Expand Up @@ -66,5 +71,7 @@ CURL_CMD="${CURL_CMD} ${GOSH_INSTANCE}"
if [[ -n ${ONLYURL+x} ]]; then
CURL_CMD="${CURL_CMD}/?onlyURL"
fi

if [[ -n ${QRCODE+x} ]]; then
CURL_CMD="${CURL_CMD}/?onlyURL -s | qrencode --size=15 -o - | xdg-open -"
fi
eval "$CURL_CMD"

0 comments on commit 2242d8b

Please sign in to comment.