From a5e34b52d76b72d047459db81d7f4e179508567c Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Mon, 12 Feb 2024 14:32:59 +0100
Subject: [PATCH] Set up wayland qr code scanner

---
 home/features/wayland/global.nix                      | 9 +++++++++
 home/features/wayland/hyprland/hyprland.conf          | 7 ++++---
 hosts/nixos/common/optional/services/acme/default.nix | 3 +--
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/home/features/wayland/global.nix b/home/features/wayland/global.nix
index 1160813..4fa8c09 100644
--- a/home/features/wayland/global.nix
+++ b/home/features/wayland/global.nix
@@ -37,11 +37,20 @@
           | ${wl-copy}
         ${_ pkgs.libnotify} "Run ocr on area with output \"$(${wl-paste})\""
       '';
+
+      wl-qr = pkgs.writeShellScriptBin "wl-qr" ''
+        ${_ pkgs.grim} -g "$(${_ pkgs.slurp})" -t ppm - \
+          | ${pkgs.zbar}/bin/zbarimg --quiet - \
+          | awk '{sub(/^QR-Code:/, "", $1); print $1}' \
+          | ${wl-copy}
+        ${_ pkgs.libnotify} "Scanned qr code on area with output \"$(${wl-paste})\""
+      '';
       # }}}
     in
     with pkgs; [
       libnotify # Send notifications
       wl-ocr # Custom ocr script
+      wl-qr # Custom qr scanner script
       wl-clipboard # Clipboard manager
       hyprpicker # Color picker
       inputs.hyprland-contrib.packages.${pkgs.system}.grimblast # Screenshot tool
diff --git a/home/features/wayland/hyprland/hyprland.conf b/home/features/wayland/hyprland/hyprland.conf
index 374a427..4e43311 100644
--- a/home/features/wayland/hyprland/hyprland.conf
+++ b/home/features/wayland/hyprland/hyprland.conf
@@ -87,9 +87,10 @@ bind = $mod, C, killactive, # Kill current
 bind = $mod, F, fullscreen, # Fullscreen
 
 # Execute external things
-bind = $mod, return, exec, wezterm # Launch wezterm
-bind = $mod, T, exec, wl-ocr # Use ocr script
-bind = $mod SHIFT, T, exec, hyprpicker | wl-copy && libnotify "Copied color $(wp-paste)" # Color picker
+bind = $mod, return, exec, wezterm
+bind = $mod, T, exec, wl-ocr
+bind = $mod SHIFT, T, exec, wl-qr
+bind = $mod CONTROL, T, exec, hyprpicker | wl-copy && libnotify "Copied color $(wp-paste)" # Color picker
 bind = $mod, Q, exec, wlogout # Show logout menu
 bind = $mod, L, exec, loginctl lock-session # Lock screen
 bind = $mod, P, exec, anyrun
diff --git a/hosts/nixos/common/optional/services/acme/default.nix b/hosts/nixos/common/optional/services/acme/default.nix
index baef068..83cc036 100644
--- a/hosts/nixos/common/optional/services/acme/default.nix
+++ b/hosts/nixos/common/optional/services/acme/default.nix
@@ -2,8 +2,7 @@
   sops.secrets.porkbun_secrets.sopsFile = ./secrets.yaml;
   security.acme.acceptTerms = true;
   security.acme.defaults = {
-    # TODO: update this email
-    email = "rafaeladriel11@gmail.com";
+    email = "acme@moonythm.dev";
     dnsProvider = "porkbun";
     environmentFile = config.sops.secrets.porkbun_secrets.path;
   };