#!/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)'