Front end for qrencode

24 risposte [Ultimo contenuto]
ssdclickofdeath
Offline
Iscritto: 05/18/2013

I made a small shell script in about 10 minutes that simplifies making QR codes with qrencode, available in Trisquel's repos. I place it into the public domain with CC0.

Enter sudo apt-get install qrencode into the terminal to install qrencode, if it hasn't been installed already.

Type chmod +x [filename here] to make the script executable.

To run the script, type ./[filename here] while in the same folder as the script.

#!/bin/bash
# This is an easy-to-use front end for qrencode, a QR code generator.
# qrencode must be installed for this script to work.
#
# To the extent possible under law, I waive all copyright and related or
# neighboring rights to this script. For more information see
# http://creativecommons.org/publicdomain/zero/1.0/.
# This work is published from the United States.

echo "Enter text for QR code:"
read STRING
echo "Enter name of file:"
read NAME
qrencode -o $NAME $STRING
exit 0;

AllegatoDimensione
qr.sh490 byte
tjp
tjp
Offline
Iscritto: 06/28/2013

This is nice, but I think I've got it working slightly better. I've attached a patch with my changes, just put the patch in the same directory as qr.sh and run

patch <qr.patch

and that should fix it up for you.

I am releasing this patch under the terms of the open source. Thank you

AllegatoDimensione
qr.patch 455 byte
ssdclickofdeath
Offline
Iscritto: 05/18/2013

I don't think using cowsay is better.
(You can use it that way, of course.)

lembas
Offline
Iscritto: 05/13/2010

The terminal averse types can add GUI dialogs easily with e.g. zenity. Left as an exercise for the reader.

Kudos for the proper hash bang, description and license! If only all scripts floating on the intarwebs had these integral parts...

ps. There's a QR code reader in the package zbar-tools. (zbarimg command)

ssdclickofdeath
Offline
Iscritto: 05/18/2013

How do I change it to accept spaces in the text? If I type in "this is a test.", the only text that gets encoded is "this".

Magic Banana

I am a member!

I am a translator!

Offline
Iscritto: 07/24/2010

Instead of:
qrencode -o $NAME $STRING
Write:
qrencode -o "$NAME" "$STRING"

ssdclickofdeath
Offline
Iscritto: 05/18/2013

Here is the fixed script.


#!/bin/bash
# This is an easy-to-use front end for qrencode, a QR code generator.
# qrencode must be installed for this script to work.
# In apt-get, run the command "sudo apt-get install qrencode".
#
# To the extent possible under law, I waive all copyright and related or
# neighboring rights to this script. For more information see
# http://creativecommons.org/publicdomain/zero/1.0/.
# This work is published from the United States.

echo "Enter text for QR code:"
read STRING
echo "Enter name of file:"
read NAME
qrencode -o "$NAME" "$STRING"
exit 0;

(The header is longer then the script!)

AllegatoDimensione
qr.sh 557 byte
ssdclickofdeath
Offline
Iscritto: 05/18/2013

The qr.sh attachment is undownloadable. I get a 403 (Forbidden) error.
Here's the file gzipped.
Another link if previous download doesn't work: http://qrshellscript.pastebay.com/1370631

AllegatoDimensione
qr.sh_.gz 363 byte
lembas
Offline
Iscritto: 05/13/2010

>The qr.sh attachment is undownloadable. I get a 403 (Forbidden) error.

For me as well. I ran into that issue earlier too
https://trisquel.info/en/issues/8153

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I'm working on a GUI based QR code reader, based on zenity. I'll post it when I'm done.

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I'm just bumping this thread so it doesn't lock.

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I can't seem to get the output from the zenity dialog box into the read [variable here] command.

lembas
Offline
Iscritto: 05/13/2010

Apparently read don't like pipes. The explanation was beyond my understanding but this works

var=$(command)

ssdclickofdeath
Offline
Iscritto: 05/18/2013

If I run this, the dialog boxes pop up and work, but nothing gets saved. The script ends with this message: "./qrgui: line 21: (I'm not copying the script line for line; it means the line with qrencode on it.) qrencode: command not found." I know that qrencode is installed; I just used it on the command line.


# To the extent possible under law, I waive all copyright and related or
# neighboring rights to this script. For more information see
# http://creativecommons.org/publicdomain/zero/1.0/.
# This work is published from the United States.
STRING=$(zenity --entry \
--title="QR Encoder" \
--text="Enter text to encode into a QR code." \
--width=250)

PATH=$(zenity --file-selection \
--title="Save QR Code" \
--save \
--confirm-overwrite)

qrencode -o $PATH "$STRING"
exit 0;

ZykoticK9
Offline
Iscritto: 04/07/2011

I'd try supplying the full path to qrencode

ssdclickofdeath
Offline
Iscritto: 05/18/2013

It works now. I can't understand why that would make a difference. Is my shell script looking for qrencode in the working directory?

ZykoticK9
Offline
Iscritto: 04/07/2011

I'd guess that PATH= probably has something to do with it?

lembas
Offline
Iscritto: 05/13/2010

https://en.wikipedia.org/wiki/PATH_%28variable%29

Better use another name for the variable.

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I have qrgui working now. I'll do some final polishing, then post the final version.

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I'm trying to upload qrgui to Gitorious, but when I enter this in the terminal:

x@Inspiron-Libre:~/git/qrgui$ git push -u origin master

I get this error:

Read from socket failed: Connection reset by peer
fatal: The remote end hung up unexpectedly

I checked, and Git is trying to connect to 87.238.52.168, which is the same as gitorious.org.

GNUser
Offline
Iscritto: 07/17/2013

I just wanted to thank ssdclickofdeath, for the work he has done here. While it might be a "simple" thing, just a frontend or a little gui for an application, the truth is, everyone here talks a lot about "free software" but it's so rare to see actual development taking place! You know like... a 80's hackers club where people would get together and write software and share code, such and such... And I think that is something that needs to be brought back. Instead of talking about free software, actually writing software and sharing it. I don't know, it just feels "right" to be that way, for us to not only talk about free software but use and create and mess around with free software. I really feel bad for having lost the habit of coding (10 years ago I would create some funny stuff with C lol).
Well, I just wanted to thank you ssdclickofdeath, and hope you will get the final version of your gui right ;)

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I didn't know that it would be this hard to debug a shell script program like this, and I'm not planning on learning more shell-scripting language any time soon, so I am abandoning this project, probably forever. I am posting my final version here; anyone should feel free to modify or complete it.

See these two links for the text version, or see the attached files.

http://qrshellscript.pastebay.com/1410001

http://pastebin.ubuntu.com/7076532/

I recommend putting the attached image in the same directory as the shell script to be the window icon.

qricon.png
AllegatoDimensione
ICONLICENSE.txt 600 byte
qrgui.tar_.gz 1.53 KB
ssdclickofdeath
Offline
Iscritto: 05/18/2013

I uploaded a semi-working version of qrgui to GitHub: https://github.com/ssdclickofdeath/qrgui

(I'd use Gitorious, but I'm having trouble pushing the first commit. I've contacted support, but GitHub will have to do in the mean time.)

lembas
Offline
Iscritto: 05/13/2010

Congrats ssdclickofdeath!

In kinda sorta related news, here's my super lame QR decoder one liner. It takes a screenshot and looks for a qr code (actually for many bar code formats) and then spits the results in a zenity window. Dependencies: scrot, zbar-tools, zenity.

scrot /tmp/scrot_'%s.png' -e 'zbarimg -q $f|sed s/QR-Code://|zenity --text-info --title="zbarimg-zenity output" --height 250 --width 400;rm -f $f'

(Public domain)

So, if you see a large enough, high quality bar code on your screen that happens to be known to zbarimg, the command should produce the decoded string. I have that on a hotkey. Since I mostly stumble upon QR codes, I added that sed replacement bit to remove the QR prefix.

ssdclickofdeath
Offline
Iscritto: 05/18/2013

I got all the bugs worked out that I am aware of. Here's version 1.0!

Direct download: http://7gfc2nsa8z.1fichier.com or http://v.gd/qk3ROf

GitHub repo: https://github.com/ssdclickofdeath/qrgui