Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ SYSTEMD_USER_UNIT_IN_FILES = \
data/systemd/redshift.service.in \
data/systemd/redshift-gtk.service.in

DBUS_SERVICE_IN_FILES = \
data/dbus-1/services/dk.jonls.redshift.Redshift.service.in
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the capitalisation of the second Redshift in the service file name. Nor the repetition of redshift. Why not just:
data/dbus-1/services/dk.jonls.redshift.service.in

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the file name here should match the well-known bus name of the Redshift service. The D-Bus spec provides an example where the well-known bus name is the same as the main interface name, and it seems that many other projects follow that convention so I copied that. The interface name is composed of a reverse-DNS part (dk.jonls.redshift) and a name (Redshift).



# Icons
if ENABLE_GUI
Expand Down Expand Up @@ -78,16 +81,28 @@ $(systemduserunit_DATA): $(SYSTEMD_USER_UNIT_IN_FILES) Makefile
sed -e "s|\@bindir\@|$(bindir)|g" $< > $@


# D-Bus service file
if ENABLE_DBUS
dbus_servicedir = @datadir@/dbus-1/services
dbus_service_DATA = $(DBUS_SERVICE_IN_FILES:.service.in=.service)
endif

$(dbus_service_DATA): $(DBUS_SERVICE_IN_FILES) Makefile
$(AM_V_GEN)$(MKDIR_P) $(@D) && \
sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@


EXTRA_DIST = \
$(EXTRA_ROOTDOC_FILES) \
$(_HICOLOR_FILES) \
$(_UBUNTU_MONO_DARK_FILES) \
$(_UBUNTU_MONO_LIGHT_FILES) \
$(_DESKTOP_FILES) \
$(SYSTEMD_USER_UNIT_IN_FILES)
$(SYSTEMD_USER_UNIT_IN_FILES) \
$(DBUS_SERVICE_IN_FILES)

CLEANFILES = $(systemduserunit_DATA)
CLEANFILES = $(systemduserunit_DATA) \
$(dbus_service_DATA)


# Update PO translations
Expand Down
27 changes: 27 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr],
[have_xcb_randr=yes], [have_xcb_randr=no])

PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no])
PKG_CHECK_MODULES([GDBUS], [gio-2.0], [have_gio=yes], [have_gio=no])
PKG_CHECK_MODULES([GEOCLUE], [geoclue], [have_geoclue=yes], [have_geoclue=no])

AC_CHECK_HEADER([windows.h], [have_windows_h=yes], [have_windows_h=no])
Expand Down Expand Up @@ -153,6 +154,30 @@ AS_IF([test "x$enable_geoclue" != xno], [
])
AM_CONDITIONAL([ENABLE_GEOCLUE], [test "x$enable_geoclue" = xyes])

# Check DBus service
AC_MSG_CHECKING([whether to enable DBus service])
AC_ARG_ENABLE([dbus], [AC_HELP_STRING([--enable-dbus],
[enable DBus service])],
[enable_dbus=$enableval],[enable_dbus=no])
AS_IF([test "x$enable_dbus" != xno], [
AS_IF([test "x$have_glib" = xyes -a "x$have_gio" = xyes -a "x$have_geoclue" = xyes], [
AC_DEFINE([ENABLE_DBUS], 1,
[Define to 1 to enable DBus service])
AC_MSG_RESULT([yes])
enable_dbus=yes
], [
AC_MSG_RESULT([missing dependencies])
AS_IF([test "x$enable_dbus" = xyes], [
AC_MSG_ERROR([missing dependencies for DBus service])
])
enable_dbus=no
])
], [
AC_MSG_RESULT([no])
enable_dbus=no
])
AM_CONDITIONAL([ENABLE_DBUS], [test "x$enable_dbus" = xyes])


# Check for GUI status icon
AC_MSG_CHECKING([whether to enable GUI status icon])
Expand Down Expand Up @@ -245,6 +270,8 @@ echo "
Location providers:
Geoclue: ${enable_geoclue}

DBus service: ${enable_dbus}

GUI: ${enable_gui}
Ubuntu icons: ${enable_ubuntu}
systemd units: ${enable_systemd} ${systemduserunitdir}
Expand Down
5 changes: 4 additions & 1 deletion contrib/redshift.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ BuildRequires: libXxf86vm-devel
BuildRequires: libxcb-devel
BuildRequires: geoclue-devel
BuildRequires: systemd
BuildRequires: glib2 >= 2.26.0

%description
Redshift adjusts the color temperature of your screen according to your
Expand Down Expand Up @@ -44,7 +45,7 @@ temperature adjustment program.
%setup -q

%build
%configure --enable-gui --enable-geoclue --enable-randr --enable-vidmode --with-systemduserunitdir=%{_userunitdir}
%configure --libexecdir=%{_libexecdir}/%{name} --enable-gui --enable-geoclue --enable-randr --enable-vidmode --enable-dbus --with-systemduserunitdir=%{_userunitdir}
make %{?_smp_mflags} V=1

%install
Expand All @@ -69,8 +70,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%defattr(-,root,root,-)
%doc COPYING NEWS README README-colorramp
%{_bindir}/redshift
%{_libexecdir}/%{name}/redshift-dbus
%{_mandir}/man1/*
%{_userunitdir}/*
%{_datadir}/dbus-1/services/dk.jonls.redshift.Redshift.service

%files -n %{name}-gtk
%defattr(-,root,root,-)
Expand Down
3 changes: 3 additions & 0 deletions data/dbus-1/services/dk.jonls.redshift.Redshift.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[D-BUS Service]
Name=dk.jonls.redshift.Redshift
Exec=@libexecdir@/redshift-dbus
48 changes: 39 additions & 9 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
# redshift Program
bin_PROGRAMS = redshift

# redshift-dbus Program
if ENABLE_DBUS
libexec_PROGRAMS = redshift-dbus
endif

redshift_SOURCES = \
redshift.c redshift.h \
colorramp.c colorramp.h \
Expand All @@ -17,38 +22,66 @@ redshift_SOURCES = \
systemtime.c systemtime.h \
gamma-dummy.c gamma-dummy.h

redshift_dbus_SOURCES = \
redshift-dbus.c \
colorramp.c colorramp.h \
solar.c solar.h \
gamma-dummy.c gamma-dummy.h

EXTRA_redshift_SOURCES = \
gamma-drm.c gamma-drm.h \
gamma-randr.c gamma-randr.h \
gamma-vidmode.c gamma-vidmode.h \
gamma-w32gdi.c gamma-w32gdi.h \
location-geoclue.c location-geoclue.h

AM_CFLAGS =
redshift_LDADD = @LIBINTL@

EXTRA_DIST =


redshift_CFLAGS =
redshift_LDADD = @LIBINTL@
redshift_dbus_CFLAGS = \
$(GLIB_CFLAGS) $(GDBUS_CFLAGS) \
$(GEOCLUE_CFLAGS)
redshift_dbus_LDADD = \
$(GLIB_LIBS) $(GDBUS_LIBS) \
$(GEOCLUE_LIBS)


if ENABLE_DRM
redshift_SOURCES += gamma-drm.c gamma-drm.h
AM_CFLAGS += $(DRM_CFLAGS)
redshift_CFLAGS += $(DRM_CFLAGS)
redshift_LDADD += \
$(DRM_LIBS) $(DRM_CFLAGS)
endif

if ENABLE_RANDR
redshift_SOURCES += gamma-randr.c gamma-randr.h
AM_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS)
redshift_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS)
redshift_LDADD += \
$(XCB_LIBS) $(XCB_CFLAGS) \
$(XCB_RANDR_LIBS) $(XCB_RANDR_CFLAGS)

redshift_dbus_SOURCES += gamma-randr.c gamma-randr.h
redshift_dbus_CFLAGS += $(XCB_CFLAGS) $(XCB_RANDR_CFLAGS)
redshift_dbus_LDADD += \
$(XCB_LIBS) $(XCB_CFLAGS) \
$(XCB_RANDR_LIBS) $(XCB_RANDR_CFLAGS)
endif

if ENABLE_VIDMODE
redshift_SOURCES += gamma-vidmode.c gamma-vidmode.h
AM_CFLAGS += $(X11_CFLAGS) $(XF86VM_CFLAGS)
redshift_CFLAGS += $(X11_CFLAGS) $(XF86VM_CFLAGS)
redshift_LDADD += \
$(X11_LIBS) $(X11_CFLAGS) \
$(XF86VM_LIBS) $(XF86VM_CFLAGS)

redshift_dbus_SOURCES += gamma-vidmode.c gamma-vidmode.h
redshift_dbus_CFLAGS += $(X11_CFLAGS) $(XF86VM_CFLAGS)
redshift_dbus_LDADD += \
$(X11_LIBS) $(X11_CFLAGS) \
$(XF86VM_LIBS) $(XF86VM_CFLAGS)
endif

if ENABLE_WINGDI
Expand All @@ -59,10 +92,7 @@ endif

if ENABLE_GEOCLUE
redshift_SOURCES += location-geoclue.c location-geoclue.h
AM_CFLAGS += \
$(GEOCLUE_CFLAGS) $(GEOCLUE_LIBS) \
$(GLIB_CFLAGS) $(GLIB_LIBS)
redshift_CFLAGS += $(GEOCLUE_CFLAGS)
redshift_LDADD += \
$(GEOCLUE_LIBS) $(GEOCLUE_CFLAGS)
$(GLIB_LIBS) $(GLIB_CFLAGS)
endif
Loading