diff options
author | Henry de Valence <hdevalence@hdevalence.ca> | 2014-03-07 02:16:06 -0500 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2014-03-20 17:27:00 +0100 |
commit | a6f07cbb0e5f20d1033502e3e5b86fe0213e7a5a (patch) | |
tree | 5f8a90908400999b35a11a96eed2e33ce36132b6 | |
parent | Outcomment .gitignore line that erroneously blocks the src/redshift-gtk dir (diff) | |
download | redshift-ng-a6f07cbb0e5f20d1033502e3e5b86fe0213e7a5a.tar.gz redshift-ng-a6f07cbb0e5f20d1033502e3e5b86fe0213e7a5a.tar.bz2 redshift-ng-a6f07cbb0e5f20d1033502e3e5b86fe0213e7a5a.tar.xz |
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.
-rw-r--r-- | HACKING | 12 | ||||
-rw-r--r-- | Makefile.am | 26 | ||||
-rw-r--r-- | configure.ac | 20 | ||||
-rw-r--r-- | data/systemd/redshift.service.in | 11 |
4 files changed, 66 insertions, 3 deletions
@@ -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: diff --git a/Makefile.am b/Makefile.am index f3109ed..f703c28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/configure.ac b/configure.ac index 550ed0f..c282e34 100644 --- a/configure.ac +++ b/configure.ac @@ -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} " diff --git a/data/systemd/redshift.service.in b/data/systemd/redshift.service.in new file mode 100644 index 0000000..bc51514 --- /dev/null +++ b/data/systemd/redshift.service.in @@ -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 |