Commit 44fb2b7afc2e
Changed files (3)
home
common
desktop
pkgs
my
scripts
bin
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