Add systemd .service file for redshift

Add a systemd user .service file to allow users to run redshift as a
daemon using systemd. Also adds a new configure option,
`--with-systemduserunitdir`, which gives the install path.

If set to `no`, systemd support is disabled.
If not set, we use `pkg-config` to find the path.
This commit is contained in:
Henry de Valence
2014-03-20 17:27:00 +01:00
committed by Jon Lund Steffensen
parent e26337db2e
commit a6f07cbb0e
4 changed files with 66 additions and 3 deletions
+10 -2
View File
@@ -8,9 +8,17 @@ The bootstrap script will use autotools to set up the build environment
and create the `configure` script.
Use `./configure --help' for options. Use `--prefix' to make an install in
your home directory. This is necessary to test python scripts. Example:
your home directory. This is necessary to test python scripts. The systemd
user unit directory should be set to avoid writing to the system location.
$ ./configure --prefix=$HOME/redshift/root
Systemd will look for the unit files in `~/.config/systemd/user` so this
directory can be used as a target if the unit files will be used. Otherwise
the location can be set to `no` to disable the systemd files.
Example:
$ ./configure --prefix=$HOME/redshift/root \
--with-systemduserunitdir=$HOME/.config/systemd/user
Now, build the files:
+25 -1
View File
@@ -2,6 +2,10 @@
SUBDIRS = src po
ACLOCAL_AMFLAGS = -I m4
# Install systemd user unit files locally for distcheck
DISTCHECK_CONFIGURE_FLAGS = \
--with-systemduserunitdir=$$dc_install_base/$(systemduserunitdir)
UPDATE_ICON_CACHE = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor || :
EXTRA_ROOTDOC_FILES = \
@@ -25,6 +29,9 @@ _UBUNTU_MONO_LIGHT_FILES = \
_DESKTOP_FILES = \
data/applications/redshift-gtk.desktop
SYSTEMD_USER_UNIT_IN_FILES = \
data/systemd/redshift.service.in
# Icons
if ENABLE_GUI
@@ -55,15 +62,32 @@ uninstall-hook:
$(UPDATE_ICON_CACHE);
endif
# man page
dist_man1_MANS = redshift.1
# Systemd service files
if ENABLE_SYSTEMD
systemduserunit_DATA = $(SYSTEMD_USER_UNIT_IN_FILES:.service.in=.service)
endif
$(systemduserunit_DATA): $(SYSTEMD_USER_UNIT_IN_FILES) Makefile
$(AM_V_GEN)$(MKDIR_P) $(@D) && \
sed -e "s|\@bindir\@|$(bindir)|g" $< > $@
EXTRA_DIST = \
$(EXTRA_ROOTDOC_FILES) \
$(_HICOLOR_FILES) \
$(_UBUNTU_MONO_DARK_FILES) \
$(_UBUNTU_MONO_LIGHT_FILES) \
$(_DESKTOP_FILES)
$(_DESKTOP_FILES) \
$(SYSTEMD_USER_UNIT_IN_FILES)
CLEANFILES = $(systemduserunit_DATA)
# Update PO translations
.PHONY: update-po
+20
View File
@@ -161,6 +161,25 @@ AS_IF([test "x$enable_ubuntu" != xno], [
])
AM_CONDITIONAL([ENABLE_UBUNTU], [test "x$enable_ubuntu" != xno])
# Check for systemd
PKG_PROG_PKG_CONFIG
AC_MSG_CHECKING([Directory to install systemd user unit files])
AC_ARG_WITH([systemduserunitdir],
[AS_HELP_STRING([--with-systemduserunitdir=<dir>],
[Directory for systemd user unit files])],
[], [with_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)])
AS_IF([test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != xno], [
AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])
AC_MSG_RESULT([$systemduserunitdir])
enable_systemd=yes
], [
AC_MSG_RESULT([not enabled])
enable_systemd=no
])
AM_CONDITIONAL([ENABLE_SYSTEMD], [test "x$enable_systemd" != xno])
# Checks for header files.
AC_CHECK_HEADERS([locale.h stdint.h stdlib.h string.h unistd.h signal.h])
@@ -200,4 +219,5 @@ echo "
GUI: ${enable_gui}
Ubuntu icons: ${enable_ubuntu}
systemd units: ${enable_systemd} ${systemduserunitdir}
"
+11
View File
@@ -0,0 +1,11 @@
[Unit]
Description=Redshift display colour temperature adjustment
Documentation=http://jonls.dk/redshift/
After=display-manager.service
[Service]
ExecStart=@bindir@/redshift
Restart=always
[Install]
WantedBy=default.target