summaryrefslogtreecommitdiff
path: root/bin/update-emacs-daemon-environment
blob: 9c1abf17f036a279d0dc622b5fae8c3c1b596c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

# Update Emacs daemon environment vars for a new interactive session.  This
# allows us to have the Emacs daemon survive restarts of the graphical desktop
# environment, and to update Emacs on a remote host when there is a new
# forwarded SSH agent socket.
#
# Note that this will start the Emacs daemon if it not up already.

which emacsclient >/dev/null || exit 0

for var in DISPLAY \
	   WAYLAND_DISPLAY \
	   SSH_ASKPASS \
	   SSH_AUTH_SOCK \
	   SSH_AGENT_PID \
	   SSH_CONNECTION \
	   WINDOWID \
	   XAUTHORITY \
	   XDG_SESSION_TYPE \
	   XDG_CURRENT_DESKTOP \
	   SWAYSOCK \
	   I3SOCK; do
    eval isset=\${$var+x}
    if [ "$isset" = "x" ]; then
	eval value=\$$var
	emacsclient -eval '(setenv "'$var'" "'$value'")'
    fi
done

# finally, also call a function which now updates the values in Eshells and
# our (Common) Lisp image(s) from Emacs' values
emacsclient -eval '(spw/propagate-new-environment)'