[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 181bd84: Include a systemd user unit file. (Bug#165
From: |
Glenn Morris |
Subject: |
[Emacs-diffs] master 181bd84: Include a systemd user unit file. (Bug#16507) |
Date: |
Sun, 13 Nov 2016 23:46:51 +0000 (UTC) |
branch: master
commit 181bd848eb9662759f076b31a32f6588e9eb58b4
Author: Glenn Morris <address@hidden>
Commit: Glenn Morris <address@hidden>
Include a systemd user unit file. (Bug#16507)
* etc/emacs.service: New file.
* doc/emacs/misc.texi (Emacs Server): Mention systemcl --user.
* Makefile.in (libdir): New, set by configure.
(systemdunitdir): New variable.
(install-etc, uninstall): Handle the emacs.service file.
---
Makefile.in | 27 +++++++++++++++++++++++++++
doc/emacs/misc.texi | 37 ++++++++++++++++++-------------------
etc/NEWS | 6 ++++++
etc/emacs.service | 17 +++++++++++++++++
4 files changed, 68 insertions(+), 19 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 3c1f29b..1095837 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -153,6 +153,9 @@ address@hidden@
# a subdirectory of this.
address@hidden@
+# Currently only used for the systemd service file.
address@hidden@
+
# Where to install Emacs's man pages.
# Note they contain cross-references that expect them to be in section 1.
address@hidden@
@@ -196,6 +199,17 @@ desktopdir=$(datarootdir)/applications
# Where the etc/emacs.appdata.xml file is to be installed.
appdatadir=$(datarootdir)/appdata
+# Where the etc/emacs.service file is to be installed.
+# The system value (typically /usr/lib/systemd/user) can be
+# obtained with: pkg-config --variable=systemduserunitdir systemd
+# but that does not respect configure's prefix.
+# It is not clear where we should install this file when
+# prefix != /usr (or /usr/local?) (eg for non-root installs).
+# Other options include ~/.config/systemd/user/,
+# $XDG_RUNTIME_DIR/systemd/user/
+# It seems the user may end up having to make a manual link...
+systemdunitdir=$(libdir)/systemd/user
+
# Where the etc/images/icons/hicolor directory is to be installed.
icondir=$(datarootdir)/icons
@@ -714,6 +728,18 @@ install-etc:
${srcdir}/etc/emacs.appdata.xml > $${tmp}; \
${INSTALL_DATA} $${tmp}
"$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"; \
rm -f $${tmp}
+ umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"
+ tmp=etc/emacs.tmpservice; rm -f $${tmp}; \
+ emacs_name=`echo emacs | sed '$(TRANSFORM)'`; \
+ exe_name=$${emacs_name}${EXEEXT}; \
+ client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
+ sed -e '/^##/d' \
+ -e "/^Documentation/ s/emacs(1)/$${emacs_name}(1)/" \
+ -e "/^ExecStart/ s|emacs|$(DESTDIR)${bindir}/$${exe_name}|" \
+ -e "/^ExecStop/ s|emacsclient|$(DESTDIR)${bindir}/$${client_name}|" \
+ ${srcdir}/etc/emacs.service > $${tmp}; \
+ $(INSTALL_DATA) $${tmp}
"$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \
+ rm -f $${tmp}
thisdir=`/bin/pwd`; \
cd ${iconsrcdir} || exit 1; umask 022 ; \
for dir in */*/apps */*/mimetypes; do \
@@ -779,6 +805,7 @@ uninstall: uninstall-$(NTDIR) uninstall-doc
fi)
-rm -f "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"
-rm -f "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"
+ -rm -f "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"
for file in snake-scores tetris-scores; do \
file="$(DESTDIR)${gamedir}/$${file}"; \
[ -s "$${file}" ] || rm -f "$$file"; \
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index f38a797..cb0a116 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1570,7 +1570,7 @@ process.
You can solve this problem by setting up Emacs as an @dfn{edit
server}, so that it ``listens'' for external edit requests and acts
-accordingly. There are two ways to start an Emacs server:
+accordingly. There are various ways to start an Emacs server:
@itemize
@findex server-start
@@ -1589,32 +1589,29 @@ calls @code{server-start} after initialization, and
returns control to
the calling terminal instead of opening an initial frame; it then
waits in the background, listening for edit requests.
address@hidden systemd unit file
address@hidden
+If your operating system uses @command{systemd} to manage startup,
+you can automatically start Emacs in daemon mode when you login
+using the supplied @dfn{systemd unit file}. To activate this:
address@hidden
+systemctl --user enable emacs
address@hidden example
+(If your Emacs was installed into a non-standard location, you may
+need to copy the @file{emacs.service} file to a standard directory
+such as @file{~/.config/systemd/user/}.)
+
@cindex socket activation, systemd, Emacs
@item
An external process can invoke the Emacs server when a connection
event occurs upon a specified socket and pass the socket to the new
-Emacs server process. An instance of this is @command{systemd}'s
-socket functionality: the @command{systemd} service creates a socket and
+Emacs server process. An instance of this is the socket functionality
+of @command{systemd}: the @command{systemd} service creates a socket and
listens for connections on it; when @command{emacsclient} connects to
it for the first time, @command{systemd} can launch the Emacs server
and hand over the socket to it for servicing @command{emacsclient}
connections. A setup to use this functionality could be:
address@hidden/.config/systemd/user/emacs.service}:
address@hidden
-[Unit]
-Description=Emacs
-
-[Service]
-Type=forking
-ExecStart=/path/to/emacs --daemon
-ExecStop=/path/to/emacsclient --eval "(kill-emacs)"
-Restart=always
-
-[Install]
-WantedBy=default.target
address@hidden example
-
@file{~/.config/systemd/user/emacs.socket}:
@example
[Socket]
@@ -1624,12 +1621,14 @@ ListenStream=/path/to/.emacs.socket
WantedBy=sockets.target
@end example
+(The @file{emacs.service} file described above must also be installed.)
+
The @code{ListenStream} path will be the path that Emacs listens for
connections from @command{emacsclient}; this is a file of your choice.
@end itemize
@cindex @env{TEXEDIT} environment variable
- Either way, once an Emacs server is started, you can use a shell
+ Once an Emacs server is started, you can use a shell
command called @command{emacsclient} to connect to the Emacs process
and tell it to visit a file. You can then set the @env{EDITOR}
environment variable to @samp{emacsclient}, so that external programs
diff --git a/etc/NEWS b/etc/NEWS
index fe76af5..03c4990 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -44,6 +44,12 @@ hand the socket over to Emacs. Emacs uses this socket to
service
emacsclient commands. This new functionality can be disabled with the
configure option '--disable-libsystemd'.
++++
+** A systemd user unit file is provided. Use it in the standard way:
+systemctl --user enable emacs
+(If your Emacs is installed in a non-standard location, you may
+need to copy the emacs.service file to eg ~/.config/systemd/user/)
+
** New configure option '--disable-build-details' attempts to build an
Emacs that is more likely to be reproducible; that is, if you build
and install Emacs twice, the second Emacs is a copy of the first.
diff --git a/etc/emacs.service b/etc/emacs.service
new file mode 100644
index 0000000..92cdeb5
--- /dev/null
+++ b/etc/emacs.service
@@ -0,0 +1,17 @@
+## If your Emacs is installed in a non-standard location, you may need
+## to copy this file to a standard directory, eg ~/.config/systemd/user/ .
+## If you install this file by hand, change the "Exec" lines below
+## to use absolute file names for the executables.
+[Unit]
+Description=Emacs text editor
+Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
+
+[Service]
+Type=forking
+ExecStart=emacs --daemon
+ExecStop=emacsclient --eval "(kill-emacs)"
+Environment=SSH_AUTH_SOCK=%t/keyring/ssh
+Restart=on-failure
+
+[Install]
+WantedBy=default.target
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 181bd84: Include a systemd user unit file. (Bug#16507),
Glenn Morris <=