Commit bff2b150097e
Changed files (3)
home
common
desktop
pkgs
my
scripts
bin
home/common/desktop/default.nix
@@ -64,6 +64,7 @@
trash-cli
walk
yt-dlp
+ yubikey-manager
];
home.pointerCursor = {
pkgs/my/scripts/bin/authkey
@@ -1,3 +1,10 @@
#!/usr/bin/env bash
set -e
-oathtool --hotp $(cat ~/.oath/key) -c $([ ! -f ~/.oath/counter ] && echo -n 0 > ~/.oath/counter || echo -n $(($(cat ~/.oath/counter)+1)) > ~/.oath/counter; cat ~/.oath/counter)
\ No newline at end of file
+
+if [ -f ~/.oath/key ]; then
+ # File-based HOTP
+ oathtool --hotp "$(cat ~/.oath/key)" -c "$([ ! -f ~/.oath/counter ] && echo -n 0 > ~/.oath/counter || echo -n $(($(cat ~/.oath/counter)+1)) > ~/.oath/counter; cat ~/.oath/counter)"
+else
+ # Fallback: YubiKey OATH
+ ykman oath accounts code --single "Red Hat:redhat" 2>/dev/null | grep -oE '[0-9]{6,8}'
+fi
\ No newline at end of file
pkgs/my/scripts/bin/redhat-vpn
@@ -17,31 +17,38 @@ if [[ "$DESKTOP" != "sway" && "$DESKTOP" != "niri" ]]; then
fi
fi
+# Use terse output with colon separators to handle multi-word names
+vpn_list=$(nmcli -t -f NAME,UUID,TYPE connection show | grep ':vpn$')
+
# Select VPN connection based on environment
if [[ GRAPHICS -eq 0 ]]; then
# Terminal: use fzf
- connection="$(nmcli connection show | grep vpn | fzf)"
+ selected="$(echo "$vpn_list" | cut -d: -f1 | fzf)"
elif [[ "$DESKTOP" == "sway" || "$DESKTOP" == "niri" ]]; then
# Wayland compositors (Sway/Niri): use fuzzel
- connection="$(nmcli connection show | grep vpn | awk '{print $1, $2, $3, $4}' | fuzzel --dmenu --prompt "VPN: ")"
+ selected="$(echo "$vpn_list" | cut -d: -f1 | fuzzel --dmenu --prompt "VPN: ")"
else
# X11: use zenity
- connection="$(nmcli connection show | grep vpn | zenity --list --title "Red Hat VPNs" --text "Choose your VPN.." --column "Name" --width=600 --height=450)"
+ selected="$(echo "$vpn_list" | cut -d: -f1 | zenity --list --title "Red Hat VPNs" --text "Choose your VPN.." --column "Name" --width=600 --height=450)"
fi
NOTIFY_CMD="notify-send"
if [[ GRAPHICS -eq 0 ]]; then
NOTIFY_CMD="echo"
fi
-uuid=$(echo "${connection}" | awk '{print $4}')
-name=$(echo "${connection}" | awk '{print $1 $2 $3}')
+name="$selected"
+uuid=$(echo "$vpn_list" | grep "^${selected}:" | cut -d: -f2)
VPNSTATUS=$(nmcli connection show --active "$uuid" | wc -l)
if [ "$VPNSTATUS" == "0" ]; then
key=$(authkey)
passfile=$(mktemp)
echo -n "vpn.secrets.password:" >"$passfile"
- passage show redhat/vpn/pass | tr -d '\r\n' 2>/dev/null >>"$passfile"
+ if [ -f ~/.oath/key ]; then
+ passage show redhat/vpn/pass | tr -d '\r\n' 2>/dev/null >>"$passfile"
+ else
+ passage show redhat/vpn/yubikey-pass | tr -d '\r\n' 2>/dev/null >>"$passfile"
+ fi
# gpg --decrypt $HOME/sync/naruhodo.pass.gpg 2>/dev/null >>"$passfile"
echo -n "${key}" >>"$passfile"