Skip to content

Instantly share code, notes, and snippets.

@RafaelPalomar
Last active March 30, 2023 05:27
Show Gist options
  • Save RafaelPalomar/ee4addc89c73e68f698954f9b13bea4e to your computer and use it in GitHub Desktop.
Save RafaelPalomar/ee4addc89c73e68f698954f9b13bea4e to your computer and use it in GitHub Desktop.
How to start emacs-daemon in a systemd service #emacs #systemd

Load Emacs as a daemon with a Systemd user unit

This gist is based on Intelligent Rumblings. Running emacs as a daemon with Systemd

First, create a systemd unit file at ~/.config/systemd/user/emacs.service:

[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=default.target

Then enable the unit:

systemctl --user enable emacs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment