[Unit] Description=Emacs [Service] Type=forking ExecStart=/usr/bin/emacs --bg-daemon=MAIN ExecStop=/usr/bin/emacsclient --socket-name=MAIN --eval "(kill-emacs)" Restart=on-failure TimeoutStartSec=0 [Install] WantedBy=default.target