diff options
Diffstat (limited to 'dot_config/hypr/scripts/executable_ssh-agent-session')
| -rw-r--r-- | dot_config/hypr/scripts/executable_ssh-agent-session | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dot_config/hypr/scripts/executable_ssh-agent-session b/dot_config/hypr/scripts/executable_ssh-agent-session new file mode 100644 index 0000000..6a05ba8 --- /dev/null +++ b/dot_config/hypr/scripts/executable_ssh-agent-session @@ -0,0 +1,24 @@ + #!/bin/sh + + agent_socket="${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR is not set}/ssh-agent.sock" + + SSH_AUTH_SOCK="$agent_socket" /usr/bin/ssh-add -l >/dev/null 2>&1 + agent_status=$? + + case "$agent_status" in + 0|1) + # Agent exists; status 1 only means it currently has no keys. + exit 0 + ;; + 2) + # No reachable agent. Remove only its stale runtime socket. + rm -f -- "$agent_socket" + exec /usr/bin/ssh-agent \ + -D \ + -a "$agent_socket" \ + -t 8h + ;; + *) + exit "$agent_status" + ;; + esac |
