Commit 44fb2b7afc2e

Vincent Demeester <vincent@sbr.pm>
2026-01-15 10:14:49
feat(yubikey): add fuzzel launcher for OATH codes
Add yubikey-oath script and desktop launcher: - Interactive fuzzel menu to select OATH account from YubiKey - Automatically copies selected code to clipboard - Shows desktop notification on success - Appears in fuzzel launcher via .desktop file Usage: Launch "YubiKey OATH" from fuzzel or run yubikey-oath from terminal Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 2ffecac
Changed files (3)
home
pkgs
my
scripts
home/common/desktop/default.nix
@@ -61,4 +61,6 @@
     source = config.lib.file.mkOutOfStoreSymlink "/home/vincent/desktop/documents/.oath";
     recursive = true;
   };
+
+  home.file.".local/share/applications/yubikey-oath.desktop".source = ./yubikey-oath.desktop;
 }
home/common/desktop/yubikey-oath.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Name=YubiKey OATH
+Comment=Get OATH code from YubiKey
+Exec=yubikey-oath
+Type=Application
+Terminal=false
+Categories=Utility;Security;
+Icon=security-high
pkgs/my/scripts/bin/yubikey-oath
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+# yubikey-oath - Select and copy OATH code from YubiKey
+
+set -euo pipefail
+
+# Check if fuzzel is available
+if ! command -v fuzzel &> /dev/null; then
+    echo "Error: fuzzel not found" >&2
+    exit 1
+fi
+
+# Check if ykman is available
+if ! command -v ykman &> /dev/null; then
+    echo "Error: ykman not found" >&2
+    exit 1
+fi
+
+# List all OATH accounts and let user select one with fuzzel
+selected=$(ykman oath accounts list 2>/dev/null | fuzzel --dmenu --prompt "OATH: " --lines 10 --width 40)
+
+if [ -z "$selected" ]; then
+    exit 0
+fi
+
+# Get the code for the selected account
+code=$(ykman oath accounts code --single "$selected" 2>/dev/null | awk '{print $NF}')
+
+if [ -z "$code" ]; then
+    notify-send "YubiKey OATH" "Failed to get code" --urgency=critical
+    exit 1
+fi
+
+# Copy to clipboard
+echo -n "$code" | pbcopy
+
+# Show notification
+notify-send "YubiKey OATH" "Code for $selected copied to clipboard" --urgency=normal
+
+exit 0