|urxvtd| can be run as a per-user service under the nosh toolset's
service manager and under systemd. It does not have the problems that
some X11 terminal emulators have with needing a |DISPLAY| environment
variable in the dæmon. But it is not perfect. In particular, one cannot
use the service managers' abilities to pass the listening socket in as
an already open file descriptor, using (in the systemd case for example)
per-user socket and service units containing things along the lines of:
[Service]
RuntimeDirectory=urxvt
RuntimeDirectoryMode=0700
ExecStart=/usr/local/bin/urxvtd
[Socket]
ListenStream=%t/urxvt/daemon
SocketMode=0600
What happens in practice is that |urxvtd| ignores the passed-in file
descriptor for a listening socket and blithely opens its own, second,
listening socket file descriptor.
The attached patch enhances |urxvtd| to interoperate with these service
management subsystems, allowing it to be passed the listening socket in
this way. It also updates |urxvtc| and the doco keeping them in step.
A possible further enhancement to the Debian package, not in this patch,
would have it install pre-made per-user units for systemd in
|/usr/lib/systemd/user/urxvtd.socket| and
|/usr/lib/systemd/user/urxvtd.service| , fleshing out the aforegiven and
allowing users to manage the urxvt dæmon with |systemctl --user|. I
leave that fairly trivial exercise to someone else. I have already
added automatically-made per-user service bundles to the nosh service
management allowing users to manage the urxvt dæmon with |system-control
--user|.
Notes:
*
This is neither Linux-specific nor systemd-specific, and should
/not/ be hidden behind a systemd configuration option. I actually
developed and tested this on FreeBSD invoking the urxvtd service
from the nosh per-user service manager.
*
The patch adds support for the |XDG_RUNTIME_DIR| environment
variable from the Freedesktop _Base Directory Specification_, which
enables using features like |RuntimeDirectory| and |%t| in systemd
units like the aforegiven.
*
Runtime directories are by definition private to individual users
and machines, and so when a runtime directory is used the socket
name is fixed as ||${XDG_RUNTIME_DIR}/urxvt/|daemon| and does not
vary by host name or unnecessarily repeat the software name.
(Compare the behaviour of other softwares which used to use compound
names in |/tmp|, such as |dbus-daemon| using just
|${XDG_RUNTIME_DIR}/bus| for example.) Per convention the |urxvt|
subdirectory does not have a hidden name (in contrast to
|${HOME}/.urxvt/|).
*
The manual pages are updated to reflect the additional environment
variables that are recognized, and to show which takes precedence.