]> gitweb.fluxo.info Git - utils-x11.git/commitdiff
Feat: qrpaste: support for content in the command line, falling back to clipboard
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 5 May 2023 03:04:20 +0000 (00:04 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 5 May 2023 03:04:20 +0000 (00:04 -0300)
qrpaste

diff --git a/qrpaste b/qrpaste
index 889bd17948a65473f2076f1ff849d144e3782849..6a30e4d83110f08d3a9d41f38f4cfd4f4207c607 100755 (executable)
--- a/qrpaste
+++ b/qrpaste
@@ -8,6 +8,7 @@ BASENAME="`basename $0`"
 TEMP="`mktemp -d`"
 OUT="$TEMP/clipboard.png"
 SIZE="15"
+ARGS="$*"
 
 # Check
 if ! which qrencode &> /dev/null; then
@@ -21,8 +22,15 @@ elif ! which display &> /dev/null; then
   exit 1
 fi
 
+# Grab the content
+if [ ! -z "$ARGS" ]; then
+  CONTENT="$ARGS"
+else
+  CONTENT="`xclip -o`"
+fi
+
 # Run
-qrencode -o "$OUT" "`xclip -o`" -s $SIZE
+qrencode -o "$OUT" "$CONTENT" -s $SIZE
 display $OUT
 
 # Teardown