Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
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
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ AS_IF([test "x$enable_geoclue" != xno], [
AM_CONDITIONAL([ENABLE_GEOCLUE], [test "x$enable_geoclue" = xyes])


# Check for interprocess communication
AC_MSG_CHECKING([whether to enable interprocess communication])
AC_ARG_ENABLE([ipc], [AC_HELP_STRING([--enable-ipc],
[enable interprocess communication])],
[enable_ipc=$enableval],[enable_ipc=yes])
AS_IF([test "x$enable_ipc" != xno], [
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
])
AM_CONDITIONAL([ENABLE_IPC], [test "x$enable_ipc" = xyes])



# Check for GUI status icon
AC_MSG_CHECKING([whether to enable GUI status icon])
AC_ARG_ENABLE([gui], [AC_HELP_STRING([--enable-gui],
Expand Down Expand Up @@ -243,6 +257,7 @@ echo "
Location providers:
Geoclue: ${enable_geoclue}

IPC: ${enable_ipc}
GUI: ${enable_gui}
Ubuntu icons: ${enable_ubuntu}
systemd units: ${enable_systemd} ${systemduserunitdir}
Expand Down
11 changes: 10 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ EXTRA_redshift_SOURCES = \
gamma-randr.c gamma-randr.h \
gamma-vidmode.c gamma-vidmode.h \
gamma-w32gdi.c gamma-w32gdi.h \
location-geoclue.c location-geoclue.h
location-geoclue.c location-geoclue.h \
server.c server.h \
service.c service.h

AM_CFLAGS =
redshift_LDADD = @LIBINTL@
redshift_LDFLAGS =
EXTRA_DIST =

if ENABLE_DRM
Expand Down Expand Up @@ -63,3 +66,9 @@ AM_CFLAGS += $(GEOCLUE_CFLAGS) $(GEOCLUE_LIBS)
redshift_LDADD += \
$(GEOCLUE_LIBS) $(GEOCLUE_CFLAGS)
endif

if ENABLE_IPC
redshift_SOURCES += server.c server.h service.c service.h
AM_CFLAGS += -DENABLE_IPC
redshift_LDFLAGS += -pthread
endif
31 changes: 31 additions & 0 deletions src/ipc-client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
# Simple manual IPC client for debugging

import os
import socket
import threading

display = os.environ["DISPLAY"] if "DISPLAY" in os.environ else ""
redshift_id = os.environ["REDSHIFT_ID"] if "REDSHIFT_ID" in os.environ else ""
path = "/dev/shm/.redshift-socket-%i-%s:%s" % (os.getuid(), display, redshift_id)

socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
socket.connect(path)

def recv_loop():
got = socket.recv(1024)
if len(got) > 0:
print(got.decode("utf-8"));

thread = threading.Thread(target = recv_loop)
thread.setDaemon(True)
thread.start()

while True:
line = input()
if line == "":
break
socket.send((line + "\n").encode("utf-8"))

socket.close()

21 changes: 17 additions & 4 deletions src/redshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
# include "location-geoclue.h"
#endif

#ifdef ENABLE_IPC
# include "service.h"
#endif


/* Union of state data for gamma adjustment methods */
typedef union {
Expand Down Expand Up @@ -263,6 +267,12 @@ static int disable = 0;
#endif /* ! HAVE_SIGNAL_H || __WIN32__ */


int temp_day = -1;
int temp_night = -1;
float brightness_day = NAN;
float brightness_night = NAN;


/* Print which period (night, day or transition) we're currently in. */
static void
print_period(double elevation)
Expand Down Expand Up @@ -661,11 +671,7 @@ main(int argc, char *argv[])
char *config_filepath = NULL;

int temp_set = -1;
int temp_day = -1;
int temp_night = -1;
float gamma[3] = { NAN, NAN, NAN };
float brightness_day = NAN;
float brightness_night = NAN;

const gamma_method_t *method = NULL;
char *method_args = NULL;
Expand Down Expand Up @@ -1220,6 +1226,9 @@ main(int argc, char *argv[])
printf("Status: %s\n", "Enabled");
}

#ifdef ENABLE_IPC
service_start();
#endif
/* Continuously adjust color temperature */
int done = 0;
int disabled = 0;
Expand Down Expand Up @@ -1254,6 +1263,10 @@ main(int argc, char *argv[])
ongoing transition */
short_trans = 0;
} else {
#ifdef ENABLE_IPC
service_close();
#endif

if (!disabled) {
/* Make a short transition
back to 6500K */
Expand Down
Loading