Skip to content

Instantly share code, notes, and snippets.

@fffx
Last active April 24, 2017 01:20
Show Gist options
  • Save fffx/6df2cb15cfef04b1f7bb731583e73ac8 to your computer and use it in GitHub Desktop.
Save fffx/6df2cb15cfef04b1f7bb731583e73ac8 to your computer and use it in GitHub Desktop.
auto start emacs server and start emacs gui from emacsclient

platform

ubuntu 16.04 emacs24

Modify emacs gui configure file

#/usr/share/applications/emacs24.desktop

TryExec=/usr/bin/emacsclient -c
Exec=/usr/bin/emacsclient -c %F

make emacs server auto start

#~/.local/share/systemd/user/emacs.service

[Unit]
Description=Emacs: the extensible, self-documenting text editor

[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Restart=always
Environment="DISPLAY=:0"

[Install]
WantedBy=default.target

enable it
$ systemctl --user enable emacs
And it can be started right away with:

$ systemctl --user start emacs

  • to stop it
    $ systemctl --user stop emacs
  • to disable it
    $ systemctl --user disable emacs

reference: https://streakycobra.github.io/posts/saas-or-spacemacs-as-a-service/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment