Skip to content

Commit

Permalink
Merge pull request #14 from FedeDP/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
FedeDP committed Nov 10, 2018
2 parents 5c1c4af + bfd3299 commit 3914db7
Show file tree
Hide file tree
Showing 28 changed files with 920 additions and 624 deletions.
2 changes: 1 addition & 1 deletion Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pkgdesc="Bus interface to change screen brightness and capture frames from webca
arch=('i686' 'x86_64')
url="https://github.com/FedeDP/${_gitname}"
license=('GPL')
depends=('systemd>=221' 'linux-api-headers' 'libx11' 'libxrandr' 'libxext' 'polkit' 'libxss' 'ddcutil')
depends=('systemd>=221' 'linux-api-headers' 'libx11' 'libxrandr' 'libxext' 'polkit' 'libxss' 'ddcutil' 'libmodule')
makedepends=('git')
optdepends=('clight-git: user service to automagically change screen backlight matching ambient brightness.')
source=("git://github.com/FedeDP/${_gitname}.git")
Expand Down
2 changes: 1 addition & 1 deletion Scripts/clightd.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requires=polkit.service

[Service]
Type=dbus
BusName=org.clightd.backlight
BusName=org.clightd.clightd
User=root
ExecStart=/usr/lib/clightd/clightd
Restart=on-failure
Expand Down
62 changes: 0 additions & 62 deletions Scripts/org.clightd.backlight.policy

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="org.clightd.backlight"/>
<allow own="org.clightd.clightd"/>
</policy>

<!-- Anyone can send messages -->
<policy context="default">
<allow send_destination="org.clightd.backlight"/>
<allow send_destination="org.clightd.clightd"/>
</policy>

</busconfig>
30 changes: 30 additions & 0 deletions Scripts/org.clightd.clightd.policy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD polkit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
<policyconfig>

<action id="org.clightd.clightd.Set">
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>

<action id="org.clightd.clightd.Capture">
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>

<action id="org.clightd.clightd.SetTimeouts">
<defaults>
<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>

</policyconfig>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[D-BUS Service]
Name=org.clightd.backlight
Name=org.clightd.clightd
Exec=/usr/lib/clightd/clightd
User=root
SystemdService=clightd.service
42 changes: 24 additions & 18 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,35 @@
- [x] Properly return value between 0 and 1.0 in CaptureWebcam
- [x] Updated api Doc
- [x] Fix udev monitors interface
- [x] Drop root privileges and gain them when needed
- [x] Leave brightness_smooth_cb if no internal backlight is present
- [x] Udev monitors must be unref'd!

### New Api (org.clightd.clightd)
- [ ] Change interface to org.clightd.clightd
- [ ] Every feature will have its own object path, eg: /org/clightd/clightd/Backlight {Set,Get}
- [ ] Sensor interface becomes: /org/clightd/clightd/Sensor org.clightd.clightd.Sensor {Capture, IsAvailable} + /org/clightd/clightd/Sensor/Als {Capture, IsAvailable} + /org/clightd/clightd/Sensor/Webcam {Capture, IsAvailable}
- [ ] Other becomes eg: /org/clightd/clightd/Backlight org.clightd.clightd.Backlight {Set/Get}
- [x] Change interface to org.clightd.clightd
- [x] Every feature will have its own object path, eg: /org/clightd/clightd/Backlight {Set,Get}
- [x] Sensor interface becomes: /org/clightd/clightd/Sensor org.clightd.clightd.Sensor {Capture, IsAvailable} + /org/clightd/clightd/Sensor/Als {Capture, IsAvailable} + /org/clightd/clightd/Sensor/Webcam {Capture, IsAvailable}
- [x] Other becomes eg: /org/clightd/clightd/Backlight org.clightd.clightd.Backlight {Set/Get}
- [x] Gamma and Backlight smooth should be equal (gamma checks if smooth is enabled and has 2 different behaviours)
- [x] Add some more MODULE_INFO
- [x] Valgrind check
- [x] Cleanup includes etc etc
- [x] Fix build with no gamma/dpms/idle...
- [x] Switch to libmodule
- [x] Sensor ctor should have priority 101, not 100 + modules_quit return err type (Wait for 3.0.0 release of libmodule)
- [x] fix "Failed to stop module." error when leaving

### New Idle interface (3.2/4.0?)
- [ ] Clightd will emit a signal (with ClientX as destination) when the timeout is reached/left. On X it will be just like dimmer clight module does now. On wayland it will use idle protocol (possibly later)
Something like:
-> /org/clightd/backlight/Idle GetClient
-> /org/clightd/backlight/Idle/Client1 SetTimeout
-> /org/clightd/backlight/Idle/Client1 SetScreen
-> /org/clightd/backlight/Idle/Client1 SetXauth (only on X)
-> /org/clightd/backlight/Idle/Client1 Start
here on X, a timerfd will be set; on Wayland, we will use idle protocol.
-> /org/clightd/backlight/Idle/Client1 Stop
here timerfd will be destroyed and Client1 removed (its object path too)
### New Idle interface
- [x] Clightd will emit a signal (with ClientX as destination) when the timeout is reached/left. On X it will be just like dimmer clight module does now. On wayland it will use idle protocol (possibly later)
- [x] It will support multiple clients
- [x] callback when changing idle client timeout: it should get current elapsed time and reset its current timer based on that (as clight does)
- [x] method_rm_client should remove vtable too!
- [x] Valgrind check!
- [x] Validate for Idle Client properties setters
- [x] Rename "Xauthority" prop to more generic "AuthCookie"

### Doc
- [ ] Update API reference
- [ ] Update any org.clightd.backlight reference
- [x] Update any org.clightd.backlight reference

## 3.1
- [ ] add support for GetSensorData android app
Expand All @@ -66,7 +70,9 @@ here timerfd will be destroyed and Client1 removed (its object path too)
https://github.com/swaywm/wlroots/blob/master/examples/gamma-control.c
https://github.com/swaywm/wlroots/blob/master/examples/idle.c
https://github.com/swaywm/sway/tree/master/swayidle
- [ ] Is dpms supported? Couldn't it be just another case for new Idle implementation? Eg: Idle after 45s -> dim screen. Idle after 5mins -> screen off.
- [ ] Couldn't DPMS be just another case for new Idle implementation? Eg: Idle after 45s -> dim screen. Idle after 5mins -> screen off
- [ ] Eventually drop dpms {Set/Get}Timeouts
- [ ] Port gamma and backlight to same "client"-like interface of idle

## Ideas
- [ ] follow ddcci kernel driver and in case, drop ddcutil and add the kernel driver as clightd opt-dep
Expand Down
14 changes: 8 additions & 6 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
BINDIR = /usr/lib/clightd
BINNAME = clightd
BUSCONFDIR = /etc/dbus-1/system.d/
BUSCONFNAME = org.clightd.backlight.conf
BUSCONFNAME = org.clightd.clightd.conf
BUSSERVICEDIR = /usr/share/dbus-1/system-services/
BUSSERVICENAME = org.clightd.backlight.service
BUSSERVICENAME = org.clightd.clightd.service
SYSTEMDSERVICE = clightd.service
SYSTEMDDIR = /usr/lib/systemd/system
POLKITPOLICYNAME = org.clightd.backlight.policy
POLKITPOLICYNAME = org.clightd.clightd.policy
POLKITPOLICYDIR = /usr/share/polkit-1/actions
MODULESLOADDDC = i2c_clightd.conf
MODULESLOADDIR = /usr/lib/modules-load.d
Expand All @@ -19,10 +19,12 @@ INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
INSTALL_DIR = $(INSTALL) -d
SRCDIR = src/
LIBS = -lm $(shell pkg-config --libs libudev)
CFLAGS = $(shell pkg-config --cflags libudev) -D_GNU_SOURCE -std=c99
LIBS = -lm $(shell pkg-config --libs libudev libmodule)
CFLAGS = $(shell pkg-config --cflags libudev libmodule) -D_GNU_SOURCE -std=c99

FOLDERS = $(subst src,.,$(sort $(dir $(wildcard $(SRCDIR)*/))))
# Recursive wildcard
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
FOLDERS = $(subst src,.,$(sort $(dir $(call rwildcard, , *.c))))
SRCS = $(addsuffix *.c, $(FOLDERS))
INCS = $(addprefix -I, $(FOLDERS))

Expand Down
7 changes: 0 additions & 7 deletions src/bus/backlight.h

This file was deleted.

10 changes: 0 additions & 10 deletions src/bus/dpms.h

This file was deleted.

11 changes: 0 additions & 11 deletions src/bus/gamma.h

This file was deleted.

54 changes: 0 additions & 54 deletions src/bus/idle.c

This file was deleted.

7 changes: 0 additions & 7 deletions src/bus/idle.h

This file was deleted.

17 changes: 15 additions & 2 deletions src/commons.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand All @@ -6,6 +8,17 @@
#include <libudev.h>
#include <unistd.h>
#include <sys/timerfd.h>
#include <privilege.h>
#include <module/modules_easy.h>

enum quit_codes { LEAVE_W_ERR = -1, SIGNAL_RCV = 1 };

typedef struct module {
const int idx;
const char *name;
int (*init)(void); // module init function
void (*destroy)(void); // module destroy function
int (*poll_cb)(const int fd); // module poll callback
} module_t;

extern sd_bus *bus;
sd_bus *bus;
struct udev *udev;
Loading

0 comments on commit 3914db7

Please sign in to comment.