Skip to content
Closed
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ before_install:
- sudo apt-get update -qq
install:
- sudo apt-get install -qq autopoint intltool
- sudo apt-get install -qq libdbus-1-dev
- sudo apt-get install -qq libdrm-dev
- sudo apt-get install -qq libxcb1-dev libxcb-randr0-dev
- sudo apt-get install -qq libx11-dev libxxf86vm-dev
- sudo apt-get install -qq libgeoclue-dev
- sudo apt-get install -qq libglib2.0-dev
- sudo apt-get install -qq python3
script: ./bootstrap && ./configure --enable-drm --enable-vidmode --enable-randr --enable-geoclue --enable-geoclue2 --enable-gui && make -j2 distcheck
script: ./bootstrap && ./configure --enable-dbus --enable-drm --enable-vidmode --enable-randr --enable-geoclue --enable-geoclue2 --enable-gui && make -j2 distcheck
85 changes: 85 additions & 0 deletions README-dbus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# DBus gamma provider for Redshift #

This provider emits colour temperature values onto DBus.

This can then be used to export the colour ramping features of Redshift into another application. An example application of this would be a program to change the colour temperature of network-controllable lighting.

## Building Redshift to support DBus

Redshift will require that you install the DBus headers. This is normally in a development package in your package manager, named something like `libdbus-1-dev`.

In order to build Redshift with DBus support, run the following:

```
./bootstrap
./configure --enable-dbus
make -j2
make install
```

### Running without Xorg / X11

You may wish to supply additional arguments to `./configure` in order to disable other gamma providers, if you are running Redshift on a system without Xorg:

```
./configure --enable-dbus --disable-drm --disable-randr --disable-vidmode --disable-quartz --disable-wingdi --disable-gui --disable-ubuntu
```

Note: you may execute with `--disable-ubuntu`, even if you are installing on Ubuntu Server. This installs extra icons which are only relevant to systems with Xorg.

### Configuring DBus to permit a user to broadcast on the System bus

Normally, DBus will prohibit users from broadcasting to the System bus. You can add a file like `/etc/dbus-1/system.d/redshift.conf` to change the permissions:

```xml
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="redshift"> <!-- This is the user redshift runs as. -->
<allow own="dk.jonls.redshift.dbus"/>
<allow send_destination="dk.jonls.redshift.dbus" send_interface="dk.jonls.Redshift"/>
<allow send_destination="dk.jonls.redshift.dbus" send_interface="org.freedesktop.DBus.Introspectable"/>
</policy>
</busconfig>
```

## Running Redshift to support DBus

If you're running headless, you probably don't have extra desktop geolocation providers like Geoclue avaliable. You'll need to manually enter your location, in latitude and longitude, as a parameter to Redshift.

You can choose whether you want to run on the System or the Session bus. You'll need to write some extra configuration for your DBus daemon in order to permit this.

For example, if you live in Sydney, Australia, and want to emit messages on the System bus, you would run Redshift with the following command:

```
redshift -m dbus -l -33.867716:151.207699
```

If you want to instead emit these messages on the Session bus (useful for local testing):

```
redshift -m dbus:session=1 -l -33.867716:151.207699
```

## DBus signals format

Redshift will emit messages from `dk.jonls.redshift.dbus` to `/dk/jonls/Redshift`, with the `dk.jonls.Redshift` interface.

You can test it with `dbus-monitor` wth the following:

```
dbus-monitor --system "type='signal',sender='dk.jonls.redshift.dbus',interface='dk.jonls.Redshift'"
```

Or with `mdbus2` with the following:

```
mdbus2 -s -l dk.jonls.redshift.dbus
```

The signals will be of type `dk.jonls.Redshift.Temperature`, which takes a single int16 argument, the desired colour temperature:

```
signal sender=:1.3738 -> dest=(null destination) serial=102 path=/dk/jonls/Redshift; interface=dk.jonls.Redshift; member=Temperature
int16 5500
```

26 changes: 26 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PKG_CHECK_MODULES([XCB_RANDR], [xcb-randr],
PKG_CHECK_MODULES([GLIB], [glib-2.0 gobject-2.0], [have_glib=yes], [have_glib=no])
PKG_CHECK_MODULES([GEOCLUE], [geoclue], [have_geoclue=yes], [have_geoclue=no])
PKG_CHECK_MODULES([GEOCLUE2], [glib-2.0 gio-2.0 >= 2.26], [have_geoclue2=yes], [have_geoclue2=no])
PKG_CHECK_MODULES([DBUS], [dbus-1], [have_dbus=yes], [have_dbus=no])

# OSX headers
AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h], [have_appserv_h=yes], [have_appserv_h=no])
Expand Down Expand Up @@ -80,6 +81,30 @@ AC_CHECK_HEADER([windows.h], [have_windows_h=yes], [have_windows_h=no])
# Check for Python
AM_PATH_PYTHON([3.2], [have_python=yes], [have_python=no])

# Check DBUS method
AC_MSG_CHECKING([whether to enable DBUS method])
AC_ARG_ENABLE([dbus], [AC_HELP_STRING([--enable-dbus],
[enable DBUS method])],
[enable_dbus=$enableval],[enable_dbus=maybe])
AS_IF([test "x$enable_dbus" != xno], [
AS_IF([test $have_dbus = yes], [
AC_DEFINE([ENABLE_DBUS], 1,
[Define to 1 to enable DBUS method])
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 method])
])
enable_dbus=no
])
], [
AC_MSG_RESULT([no])
enable_dbus=no
])
AM_CONDITIONAL([ENABLE_DBUS], [test "x$enable_dbus" = xyes])

# Check DRM method
AC_MSG_CHECKING([whether to enable DRM method])
AC_ARG_ENABLE([drm], [AC_HELP_STRING([--enable-drm],
Expand Down Expand Up @@ -364,6 +389,7 @@ echo "
ldflags: ${LDFLAGS}

Adjustment methods:
DBUS: ${enable_dbus}
DRM: ${enable_drm}
RANDR: ${enable_randr}
VidMode: ${enable_vidmode}
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ src/redshift.c

src/config-ini.c

src/gamma-dbus.c
src/gamma-drm.c
src/gamma-randr.c
src/gamma-vidmode.c
Expand Down
Loading