Skip to content

Commit 3d13306

Browse files
committed
Fix SSH agent on Wayland
1 parent 9ebe4f4 commit 3d13306

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

.profile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ fi
3232

3333
# Pre-startup scripts don't seem to work on Plasma Wayland,
3434
# and therefore the pre-startup script has to be loaded here.
35-
. "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"
35+
# . "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"
36+
if [ -f "${HOME}/.ssh-agent-info" ]; then
37+
eval "$(<"${HOME}/.ssh-agent-info")" > /dev/null
38+
fi

startup/agx-user-pre-startup.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,24 @@
1313
export SSH_ASKPASS="/usr/bin/ksshaskpass"
1414
export SSH_ASKPASS_REQUIRE=prefer
1515

16-
if ! pgrep -u "${USER}" ssh-agent > /dev/null; then
16+
# Wait for kwallet
17+
# This is necessary on Wayland, but not on X11
18+
# if command -v kwallet-query &> /dev/null; then
19+
# kwallet-query -l kdewallet > /dev/null
20+
# fi
21+
22+
SSH_AGENT_UPDATED=false
23+
# Pgrep finds regexes, and without the specification for the start and end of the line,
24+
# it could find e.g. the gcr-ssh-agent provided by the package gcr,
25+
# and not start the correct SSH agent.
26+
if ! pgrep -u "${USER}" '^ssh-agent$' > /dev/null; then
1727
# echo "SSH agent seems not to be started. Starting, and saving its configuration."
18-
ssh-agent > ~/.ssh-agent-info
28+
ssh-agent > "${HOME}/.ssh-agent-info"
29+
SSH_AGENT_UPDATED=true
1930
fi
20-
if [[ "${SSH_AGENT_PID}" == "" ]]; then
31+
if [[ "${SSH_AGENT_PID}" == "" ]] || [ "${SSH_AGENT_UPDATED}" = true ]; then
2132
# echo "SSH agent configuration seems not to be loaded. Loading."
22-
eval "$(<~/.ssh-agent-info)" > /dev/null
33+
eval "$(<"${HOME}/.ssh-agent-info")" > /dev/null
2334
fi
2435

2536
# echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${LOG_PATH}"

startup/agx-user-startup.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ set -u
66
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
77
REPO_DIR="$(dirname "${SCRIPT_DIR}")"
88

9+
if command -v kwallet-query &> /dev/null; then
10+
kwallet-query -l kdewallet > /dev/null
11+
fi
12+
913
# Run the pre-startup script again to ensure that the SSH agent is available
10-
# . "${SCRIPT_DIR}/agx-user-pre-startup.sh"
14+
. "${SCRIPT_DIR}/agx-user-pre-startup.sh"
1115

1216
echo "Starting SSH agent configuration script."
1317
SETUP_AGENT="${REPO_DIR}/ssh/setup_agent.sh"

zsh/.zshenv

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
ZDOTDIR="${HOME}/Git/linux-scripts/zsh"
22

33
if [ -f "${HOME}/.cargo/env" ]; then
4-
. "${HOME}/.cargo/env"
4+
. "${HOME}/.cargo/env"
55
fi
66

77
# Pre-startup scripts don't seem to work on Plasma Wayland,
88
# and therefore the pre-startup script has to be loaded here.
9-
. "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"
9+
# . "${HOME}/Git/linux-scripts/startup/agx-user-pre-startup.sh"
10+
if [ -f "${HOME}/.ssh-agent-info" ]; then
11+
eval "$(<"${HOME}/.ssh-agent-info")" > /dev/null
12+
fi

0 commit comments

Comments
 (0)