Jack encountered some problems configuring the Emacs daemon. Configuring Emacs to run as a background process at boot time is the standard recommendation to significantly improve Emacs startup time.

As I have also previously struggled (and given up) with this issue, here's how I finally resolved the issue on my environment (Arch Linux, 7.0.10 kernel, GNOME v50, Wayland).

Test the Emacs client server

Initially, I manually ran the Emacs daemon (as documented in the manual) and tested invoking emacs using the emacsclient command.

$ emacs --fg-daemon               # Run the daemon in the foreground to see any messages
$ emacsclient --create-frame      # Invoke emacs client

This worked OK although I noted a couple of minor issues:

Dashboard package

The dashboard package needed a (documented) minor configuration change.

(setq initial-buffer-choice 'dashboard-open)

I also added another configuration entry to ensure the dashboard was correctly refreshed (recent files) when opening a new frame

(add-hook 'server-after-make-frame-hook 'dashboard-open))

Configure systemd

The Emacs distribution includes a sample systemd unit configuration file (under etc/emacs.service).

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

[Service]
Type=notify
ExecStart=emacs --fg-daemon

# Emacs will exit with status 15 after having received SIGTERM, which
# is the default "KillSignal" value systemd uses to stop services.
SuccessExitStatus=15

# The location of the SSH auth socket varies by distribution, and some
# set it from PAM, so don't override by default.
# Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=default.target

A couple of minor changes were required here:

  • Configure the Emacs service as a user (not system) service.
  • Ensure the Emacs daemon waits for the Wayland/X server to fully initialise.
  • To avoid the Authorization required, but no authorization protocol specified error, run the Emacs daemon in the background (use --daemon instead of --fg-daemon).
$ diff /usr/local/lib/systemd/user/emacs.service etc/emacs.service
4d7
< After=graphical-session.target
8,9c11
< ExecStart=/usr/local/bin/emacs --daemon
---
> ExecStart=emacs --fg-daemon

It was very tricky to get Emacs to honour the initial frame properties (height, width) correctly. Eventually I gave up and configured this in the Emacs configuration (which worked fine).

(use-package frame
  :ensure nil
  :config
  ;; Set initial frame properties (dimensions and font)
  (add-to-list 'default-frame-alist '(height . 50))
  (add-to-list 'default-frame-alist '(width . 100))
  (add-to-list 'default-frame-alist '(font . "Inconsolata-11")))