Starting Emacs on boot

I use Emacs all the time. My most important Emacs runs in my own server, which I access remotely either through a tty terminal, or a graphical session. The terminal can either be plain ssh, or mosh. The graphical session is x2go at the moment.

Since I always want an Emacs running, and I want to access the same emacs session in different ways, its convenient to start Emacs on boot.

The file /etc/systemd/system/emacs@.service:

 1[Unit]
 2Description=Emacs: the extensible, self-documenting text editor
 3
 4[Service]
 5Type=forking
 6ExecStart=/usr/bin/emacs --daemon
 7ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
 8Restart=always
 9User=%i
10WorkingDirectory=%h
11
12[Install]
13WantedBy=multi-user.target

Then in my case:

1systemctl enable emacs@joakim
2systemctl start emacs@joakim

I have been using this for a while and it works pretty well!