aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/.zprofile
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-08-11 21:32:12 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2014-08-11 21:32:12 +0200
commit75a903d038b6141f577aad480a4667162d32080e (patch)
treeaaf9b3a8b9e76e723e68d3e7011496e0547e4a27 /zsh/.zprofile
parent9517933dc4ad364060a831b19fcb8fddb12b2c4a (diff)
downloaddotfiles-75a903d038b6141f577aad480a4667162d32080e.tar.xz
zprofile: Switch from gnome-keyring to gpg/ssh-agent
Diffstat (limited to 'zsh/.zprofile')
-rw-r--r--zsh/.zprofile23
1 files changed, 21 insertions, 2 deletions
diff --git a/zsh/.zprofile b/zsh/.zprofile
index a2be301..0871e85 100644
--- a/zsh/.zprofile
+++ b/zsh/.zprofile
@@ -41,8 +41,27 @@ export FQDN=$(hostname -f)
# LS_COLORS is now required for `ls` to use colour
source <(dircolors -b "$XDG_CONFIG_HOME"/dircolors)
-[[ -S '/run/user/1000/keyring/gpg' ]] && export GPG_AGENT_INFO='/run/user/1000/keyring/gpg:0:1'
-[[ -S '/run/user/1000/keyring/ssh' ]] && export SSH_AUTH_SOCK='/run/user/1000/keyring/ssh'
+function {
+ local envfile="$XDG_RUNTIME_DIR"/gpg-agent.env
+ if [[ -e "$envfile" ]] && kill -0 $(cut -d':' -f2 <"$envfile") &>/dev/null; then
+ source "$envfile"
+ else
+ source <(gpg-agent --daemon --write-env-file "$envfile")
+ export GPG_AGENT_INFO
+ fi
+}
+
+function {
+ local envfile="$XDG_RUNTIME_DIR"/ssh-agent.env
+ local pid=$(awk -F'[=;]' 'FNR == 2 {print $2}' "$envfile" 2>/dev/null)
+
+ if [[ -n "$pid" ]] && kill -0 "$pid" &>/dev/null; then
+ source "$envfile" >/dev/null
+ else
+ ssh-agent > "$envfile"
+ source "$envfile" >/dev/null
+ fi
+}
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
exec startx "$XDG_CONFIG_HOME"/X11/xinitrc