From a3e77a96610c9789e173ec50fd15c2e308b9a1c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Wed, 27 Mar 2024 12:40:22 -0300 Subject: [PATCH] scripts: add script to read QR codes --- scripts/default.nix | 1 + scripts/readQrCode | 18 ++++++++++++++++++ user/desktop-entries.nix | 9 +++++++++ user/pass.nix | 1 + 4 files changed, 29 insertions(+) create mode 100755 scripts/readQrCode diff --git a/scripts/default.nix b/scripts/default.nix index 844308b..54ee0a2 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -50,6 +50,7 @@ create_scripts color_picker = [ grim slurp wl-clipboard libnotify imagemagick ]; dzadd = [ procps libnotify final.wdmenu jq mpv pqiv python3Packages.deemix mpc-cli final.mpdDup ]; mpdDup = [ mpc-cli perl ]; + readQrCode = [ grim zbar wl-clipboard ]; } // lib.mapAttrs import_script { wdmenu = ./wdmenu.nix; wlauncher = ./wlauncher.nix; diff --git a/scripts/readQrCode b/scripts/readQrCode new file mode 100755 index 0000000..a86de59 --- /dev/null +++ b/scripts/readQrCode @@ -0,0 +1,18 @@ +#!/bin/sh + +set -o pipefail + +main() { + + if wl-paste | zbarimg -q --raw - | wl-copy + then + notify-send "Copied" "QrCode was copied to clipboard" + rm "$LOGFILE" + else + notify-send "Failed to read QrCode" "Log file is '$LOGFILE'" + fi + +} + +LOGFILE=$(mktemp /tmp/qrcode-XXXXXXXX.log) +main > "$LOGFILE" 2>&1 diff --git a/user/desktop-entries.nix b/user/desktop-entries.nix index cb42d40..eaa4c93 100644 --- a/user/desktop-entries.nix +++ b/user/desktop-entries.nix @@ -54,5 +54,14 @@ icon = "download"; categories = [ "Network" ]; }; + readQrCode = { + name = "Read QR Code"; + genericName = "Read QR Code from clipboard image"; + exec = "readQrCode"; + terminal = true; + type = "Application"; + icon = "download"; + categories = [ "Network" ]; + }; }; } diff --git a/user/pass.nix b/user/pass.nix index 324caa2..365706c 100644 --- a/user/pass.nix +++ b/user/pass.nix @@ -20,6 +20,7 @@ wpass _gpg-unlock qtpass + readQrCode ]; }; }