summaryrefslogtreecommitdiff
path: root/bin/update-emacs-daemon-environment
blob: c36586c938a9287cf42175de5f995adc25f53d27 (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
#!/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 \
	   SSH_ASKPASS \
	   SSH_AUTH_SOCK \
	   SSH_AGENT_PID \
	   SSH_CONNECTION \
	   WINDOWID \
	   XAUTHORITY \
	   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 Lisp image from Emacs' values
emacsclient -eval '(spw/propagate-new-environment)'