[PATCH] darwin: require X display for showing QR code with Image/GraphicsMagick

cong.ma at obspm.fr cong.ma at obspm.fr
Wed May 3 12:06:37 CEST 2017


From: Cong Ma <cong.ma at obspm.fr>

Both ImageMagick and GraphicsMagick's "display" command should require a
working X display.  The mere presence of the "display" command doesn't
guarantee runtime success.  If there's no X running, the "display"
command will be selected for showing the QR code, but then fail.

Fix this by guarding the conditional for selecting them with a test on
"$DISPLAY".  If this test fails, it falls back to "qrencode -t utf8."
---
 src/platform/darwin.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/platform/darwin.sh b/src/platform/darwin.sh
index 86eb325..b6413fd 100644
--- a/src/platform/darwin.sh
+++ b/src/platform/darwin.sh
@@ -34,10 +34,12 @@ tmpdir() {
 qrcode() {
 	if type imgcat >/dev/null 2>&1; then
 		echo -n "$1" | qrencode --size 10 -o - | imgcat
-	elif type gm >/dev/null 2>&1; then
+	elif [ -n "$DISPLAY" ]; then
+	    if type gm >/dev/null 2>&1; then
 		echo -n "$1" | qrencode --size 10 -o - | gm display -title "pass: $2" -geometry +200+200 -
-	elif type display >/dev/null 2>&1; then
+	    elif type display >/dev/null 2>&1; then
 		echo -n "$1" | qrencode --size 10 -o - | display -title "pass: $2" -geometry +200+200 -
+	    fi
 	else
 		echo -n "$1" | qrencode -t utf8
 	fi
-- 
2.12.2



More information about the Password-Store mailing list