Coder Social home page Coder Social logo

fededp / clight Goto Github PK

View Code? Open in Web Editor NEW
694.0 7.0 27.0 1.55 MB

A C daemon that turns your webcam into a light sensor. It will adjust screen backlight based on ambient brightness.

License: GNU General Public License v3.0

Shell 1.53% C 94.77% CMake 2.39% Roff 1.30%
daemon c linux webcam capture-frames screen-backlight gamma-correction brightness capture battery

clight's People

Contributors

danyspin97 avatar erikpitko avatar fededp avatar ferki avatar frauh0lle avatar ilmaz13 avatar mendelmunkis avatar nicholas85 avatar sonico98 avatar tecosaur avatar thecsw avatar timgates42 avatar tpeacock19 avatar vorpalblade avatar yochananmarqos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

clight's Issues

Location don't switch from hard dep to soft dep after setting manually.

When I set location manually in config file, or in command line (or both) location module is disabled, which is expected, but after that gamma module is also disabled because the lack of location module.
In src/location.c there is a function that should switch location from hard dep to soft dep, but it doesn't working for some reason.

Trying to start Gamma module as its Xorg dependency was loaded...
Trying to start GammaSmooth module as its Xorg dependency was loaded...
Trying to start Dimmer module as its Xorg dependency was loaded...
Trying to start DimmerSmooth module as its Xorg dependency was loaded...
Trying to start Dpms module as its Xorg dependency was loaded...
Trying to start Inhibit module as its Xorg dependency was loaded...
Trying to start Brightness module as its Bus dependency was loaded...
Trying to start Location module as its Bus dependency was loaded...
Location module disabled.
Disabling module Gamma as its hard dep Location was disabled...
Gamma module disabled.
Trying to start Brightness module as its Gamma soft dep was disabled...
Disabling module GammaSmooth as its hard dep Gamma was disabled...
GammaSmooth module disabled.
GammaSmooth module destroyed.
Gamma module destroyed.
Location module destroyed.

When I remove manual location setting the geoclue2 kicks in and everything is working as expected.

System: Arch Linux
Clight installed from AUR.
I would gladly provide more info when necessary.

segmentation fault, loading dimmer if inhibition is disabled

I'm testing this on Lubuntu 16.04, and by some reason gdb is unable to give any useful backtrace here.

EDIT: if inhibition is enabled, it says, that PM inhibition appears to be unsupported, but tries to start dimmer (init is called), then adds its callback. Later inhibition is destroyed, but dimmer is not.

If inhibition is disabled, callback is not added before to destroy unused modules.
UserBus and Inhibit modues are destroyed at this stage, then it crashes (these are messages).

DE Integration Wiki

Here are additional example scripts if you want to add them to the wiki. Or you could just mention that it can be done on GNOME & Cinamon via gsettings.

GNOME

#!/usr/bin/env python

import dbus
import subprocess
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop

old_time = -1; # 0 -> day, 1 -> night

def handle_time_change(*args):
    global old_time
    if 'Time' in args[1] and old_time != args[1]['Time']:
        if args[1]['Time'] == 1:
			# Applications
			subprocess.Popen(["gsettings set org.gnome.desktop.interface gtk-theme", "Matcha-dark-sea"])
			# Cursor
			subprocess.Popen(["gsettings set org.gnome.desktop.interface cursor-theme", "xcursor-breeze-snow"])
			# Icons
			subprocess.Popen(["gsettings set org.gnome.desktop.interface icon-theme", "Papirus-Dark-Maia"])
			# Shell
			subprocess.Popen(["gsettings set org.gnome.shell.extensions.user-theme name", "Matcha-dark-sea"])
        elif args[1]['Time'] == 0:
			# Applications
			subprocess.Popen(["gsettings set org.gnome.desktop.interface gtk-theme", "Matcha-sea"])
			# Cursor
			subprocess.Popen(["gsettings set org.gnome.desktop.interface cursor-theme", "xcursor-breeze"])
			# Icons
			subprocess.Popen(["gsettings set org.gnome.desktop.interface icon-theme", "Papirus-Maia"])
			# Shell
			subprocess.Popen(["gsettings set org.gnome.shell.extensions.user-theme name", "Matcha-sea"])
        old_time = args[1]['Time']

DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(
    handle_time_change,
    'PropertiesChanged',
    'org.freedesktop.DBus.Properties',
    path='/org/clight/clight'
)

loop = GLib.MainLoop().run()

Cinnamon

#!/usr/bin/env python

import dbus
import subprocess
from gi.repository import GLib
from dbus.mainloop.glib import DBusGMainLoop

old_time = -1; # 0 -> day, 1 -> night

def handle_time_change(*args):
    global old_time
    if 'Time' in args[1] and old_time != args[1]['Time']:
        if args[1]['Time'] == 1:
			# Window borders
			subprocess.Popen(["gsettings set org.cinnamon.desktop.wm.preferences theme", "Matcha-dark-sea"])
			# Icons
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface icon-theme", "Papirus-Dark-Maia"])
			# Controls
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface gtk-theme", "Matcha-dark-sea"])
			# Mouse Pointer
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface cursor-theme", "xcursor-breeze-snow"])
			# Desktop
			subprocess.Popen(["gsettings set org.cinnamon.theme name", "Matcha-dark-sea"])
        elif args[1]['Time'] == 0:
			# Window borders
			subprocess.Popen(["gsettings set org.cinnamon.desktop.wm.preferences theme", "Matcha-sea"])
			# Icons
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface icon-theme", "Papirus-Maia"])
			# Controls
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface gtk-theme", "Matcha-sea"])
			# Mouse Pointer
			subprocess.Popen(["gsettings set org.cinnamon.desktop.interface cursor-theme", "xcursor-breeze"])
			# Desktop
			subprocess.Popen(["gsettings set org.cinnamon.theme name", "Matcha-sea"])
        old_time = args[1]['Time']

DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
bus.add_signal_receiver(
    handle_time_change,
    'PropertiesChanged',
    'org.freedesktop.DBus.Properties',
    path='/org/clight/clight'
)

loop = GLib.MainLoop().run()

clight does not start

Hi! Great initiative, especially since there's no non-Xorg standard tool to write backlight sysfs attributes. I've install both clight{,d}-git AUR packages, but there are a few errors. clight-git post install message says to enable systemctl --user enable clight.timer but there's not such unit file.

Then I've started/enabled the systemd system service for clightd with:

sudo systemctl enable clightd.service
sudo systemctl start clightd.service

but I get this while running clight:

$ clight
Config file /home/vivien/.config/clight.conf not found.
check(): Connection reset by peer
Upower appears to be unsupported.
check_clightd_version(): Transport endpoint is not connected
No clightd found. Clightd is a mandatory dep.
No functional module is running. Nothing to do...leaving.

I know clight wants to be zero-conf, so I'm wondering what's wrong! :-)

I'm currently running Archlinux without DM/DE, only systemd-logind, wayland and Sway 0.15. I'm not expecting gamma to work until I upgrade to Sway 1.0, but in the meantime, automatic control of the brightness would make me happy.

P.S.: is it clightd's job to remember the backlight brightness value and reset on next boot or not? This is what systemd-backlight is doing, I'm wondering if it must be disabled when clightd is enabled or not.

P.P.S.: I like the idea of using the webcam to capture ambient light, but I'm a paranoid user with a ThinkShutter to block it when not in use. Does clight ignore a black capture or would that mess up my brightness settings? What I'm imagining doing is opening the cam shutter when I want accurate settings from clightd and eventually manually trigger an update with clight.

Thank you!

External monitor not dimming

Thanks for this great utility!

I'm working to get my external monitor connected through an HDMI port on mu xubuntu installation to dim with clight, but it doesn't dim.

Here is the result of clight --verbose:

clight  --verbose
SIGNAL module started.
BUS module started.
USERBUS module being started as submodule of BUS...
USERBUS module started.
INTERFACE module being started as submodule of USERBUS...
INTERFACE module started.
Trying to start BACKLIGHT module as its INTERFACE dependency was loaded...
Trying to start GAMMA module as its INTERFACE dependency was loaded...
Trying to start DIMMER module as its INTERFACE dependency was loaded...
XORG module started.
Trying to start GAMMA module as its XORG dependency was loaded...
Trying to start DIMMER module as its XORG dependency was loaded...
Trying to start DPMS module as its XORG dependency was loaded...
Trying to start LOCATION module as its BUS dependency was loaded...
Set timeout of 3s 0ns on fd 7.
LOCATION module started.
Trying to start UPOWER module as its BUS dependency was loaded...
UPOWER module started.
Trying to start BACKLIGHT module as its UPOWER dependency was loaded...
Trying to start DIMMER module as its UPOWER dependency was loaded...
Trying to start DPMS module as its UPOWER dependency was loaded...
Trying to start CLIGHTD module as its BUS dependency was loaded...
Clightd found, version: 3.0.
CLIGHTD module started.
Trying to start BACKLIGHT module as its CLIGHTD dependency was loaded...
Trying to start GAMMA module as its CLIGHTD dependency was loaded...
Trying to start DIMMER module as its CLIGHTD dependency was loaded...
Trying to start DPMS module as its CLIGHTD dependency was loaded...
Setted DPMS timeouts: Standby -> 300s, Suspend -> 420s, Off -> 600s.
DPMS module started.
Callback added for module DPMS on module UPOWER bus match.
Callback added for module DPMS on module INTERFACE bus match.
Trying to start INHIBIT module as its USERBUS dependency was loaded...
INHIBIT module started.
Trying to start DIMMER module as its INHIBIT dependency was loaded...
Loading loc from cache file: No such file or directory
Trying to start GAMMA module as its LOCATION dependency was loaded...
Set timeout of 0s 1ns on fd 8.
GAMMA module started.
Callback added for module GAMMA on module LOCATION bus match.
Callback added for module GAMMA on module INTERFACE bus match.
set_temp(): Unknown object '/org/clightd/clightd/Gamma'.
Next gamma alarm due to: Fri Dec  7 23:17:00 2018
Set timeout of 11891s 0ns on fd 8.
Trying to start BACKLIGHT module as its GAMMA dependency was loaded...
AC curve: y = -0.024825 + 0.191641x + -0.008928x^2
BATT curve: y = -0.010629 + 0.153844x + -0.007284x^2
Set timeout of 0s 1ns on fd 9.
BACKLIGHT module started.
Callback added for module BACKLIGHT on module UPOWER bus match.
Callback added for module BACKLIGHT on module INTERFACE bus match.
Callback added for module BACKLIGHT on module INTERFACE bus match.
Callback added for module BACKLIGHT on module INTERFACE bus match.
Average frames brightness: 0.065059.
Ambient brightness: 0.065 -> Backlight pct: 0.086
Set timeout of 5400s 0ns on fd 9.
Trying to start DIMMER module as its BACKLIGHT dependency was loaded...
idle_get_client(): Unknown object '/org/clightd/clightd/Idle'.
Clight Idle error.
Error while loading DIMMER module.
DIMMER module disabled.
INHIBIT module disabled.
INHIBIT module destroyed.
DIMMER module destroyed.

Running the default config. Using X11 rather than Wayland.

Is there anything obvious I should do or check? I've installed ddcutil. Thanks for your help!

Also, the Gamma doesn't seem to be working. Thoughts there?

segmentation fault in backlight module

I build clight deb in lubuntu 16.04 i386. Runing without no_backlight in config causes it to crash.
After doing make debug and runing in gdb from source dir, i got backtrace with 12 levels, but without function names, only two lowest levels are:

#11..... __libc_start_main() from libc
#12..... ?? from /lib/ld-linux.so.2
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Disabling gamma support as X is not running.

There seems to be a glitch when clight is trying to get the location. After startup, my clight.log looks like this:

(I) Disabling gamma support as X is not running.
Clight
Version: 0.9
Time: Thu Apr 20 07:24:08 2017

Starting options:
* Number of captures: 5
* Daily timeout: 600
* Nightly timeout: 2700
* Webcam device: 
* Backlight path: 
* Daily screen temp: 6500
* Nightly screen temp: 4000
* Smooth transitions: enabled
* Latitude: 0.00
* Longitude: 0.00
* User setted sunrise: 
* User setted sunset: 
* Gamma correction: disabled

(I) Bus support started.
(I) Brightness module started.
(I) Signal module started.
(I) Average frames brightness: 0.118881.
(I) Old brightness value: 259
(I) New brightness value: 111

Thus the gamma correction/location module is disabled.
After running systemctl --user restart clight.service it changes to:

Clight
Version: 0.9
Time: Thu Apr 20 07:53:40 2017

Starting options:
* Number of captures: 5
* Daily timeout: 600
* Nightly timeout: 2700
* Webcam device: 
* Backlight path: 
* Daily screen temp: 6500
* Nightly screen temp: 4000
* Smooth transitions: enabled
* Latitude: 0.00
* Longitude: 0.00
* User setted sunrise: 
* User setted sunset: 
* Gamma correction: enabled

(I) Bus support started.
(I) Brightness module started.
(I) Location module started.
(I) Gamma module started.
(I) Signal module started.
(I) Dpms module started.
(I) New location received: 47.62, 7.67
(I) Average frames brightness: 0.369102.
(I) Old brightness value: 112
(I) New brightness value: 345
(I) Gamma temp was already 6500
(I) Next gamma alarm due to: Thu Apr 20 19:52:00 2017

Gamma correction doesn't work on arch liunx

Hi,
I've installed clight-git arch Linux from aur.
Clight changes backlight correct, but no gamma-correction is pressent.

I use i3 as wm.

~ % pacman -Qi clight-git
Name : clight-git
Version : r341.42747ad-1
Description : A C daemon that turns your webcam into a light sensor. It can also change display gamma temperature.
Architecture : x86_64
URL : https://github.com/FedeDP/Clight
Licenses : GPL
Groups : None
Provides : None
Depends On : systemd popt libconfig gsl clightd-git
Optional Deps : geoclue2: to retrieve user location through geoclue2. [installed]
upower: to save energy by increasing timeouts between captures while on battery. [installed]
Required By : None
Optional For : clightd-git
Conflicts With : None
Replaces : None
Installed Size : 87.00 KiB
Packager : Unknown Packager
Build Date : Sat 10 Feb 2018 10:30:45 PM CET
Install Date : Sat 10 Feb 2018 10:30:45 PM CET
Install Reason : Explicitly installed
Install Script : Yes
Validated By : None

The content of the .clight.log is: (I cencored the location in logfile)

Clight

  • Software version: 1.4
  • Starting time: Tue Feb 13 11:08:54 2018

Starting options:

Generic

  • Verbose (debugging): Enabled
  • Number of captures: 5
  • Webcam device: Unsetted
  • Backlight path: intel_backlight
  • User position: xx.xx xx.xx
  • Daily screen temp: 6500
  • Nightly screen temp: 4000
  • User setted sunrise: Unsetted
  • User setted sunset: Unsetted
  • Event duration: 2700
  • Dimmer backlight: 20%

Timeouts

  • Daily timeouts: AC 600 BATT 1200
  • Nightly timeout: AC 2700 BATT 5400
  • Event timeouts: AC 300 BATT 600
  • Dimmer timeouts: AC 300 BATT 45
  • Weather timeouts: AC 3600 BATT 10800
  • Dpms timeouts: AC 900:1200:1800 BATT 150:210:300

Modules

  • Gamma smooth trans: Enabled
  • Dimmer smooth trans: Enabled
  • Gamma correction: Enabled
  • Screen dpms tool: Enabled
  • Weather support: Enabled
  • Screen dimmer tool: Enabled

(D)[11:08:54]{modules.c:59} Signal module started.
(D)[11:08:54]{modules.c:59} Bus module started.
(D)[11:08:54]{modules.c:96} UserBus module being started as submodule of Bus...
(D)[11:08:54]{modules.c:59} UserBus module started.
(D)[11:08:54]{modules.c:190} Xorg module disabled.
(D)[11:08:54]{modules.c:200} Disabling module Gamma as its hard dep Xorg was disabled...
(D)[11:08:54]{modules.c:190} Gamma module disabled.
(D)[11:08:54]{modules.c:203} Trying to start Brightness module as its Gamma soft dep was disabled...
(D)[11:08:54]{modules.c:200} Disabling module GammaSmooth as its hard dep Gamma was disabled...
(D)[11:08:54]{modules.c:190} GammaSmooth module disabled.
(D)[11:08:54]{modules.c:250} GammaSmooth module destroyed.
(D)[11:08:54]{modules.c:250} Gamma module destroyed.
(D)[11:08:54]{modules.c:200} Disabling module Dimmer as its hard dep Xorg was disabled...
(D)[11:08:54]{modules.c:190} Dimmer module disabled.
(D)[11:08:54]{modules.c:200} Disabling module DimmerSmooth as its hard dep Dimmer was disabled...
(D)[11:08:54]{modules.c:190} DimmerSmooth module disabled.
(D)[11:08:54]{modules.c:250} DimmerSmooth module destroyed.
(D)[11:08:54]{modules.c:190} Inhibit module disabled.
(D)[11:08:54]{modules.c:190} UserBus module disabled.
(D)[11:08:54]{modules.c:250} UserBus module destroyed.
(D)[11:08:54]{modules.c:250} Inhibit module destroyed.
(D)[11:08:54]{modules.c:250} Dimmer module destroyed.
(D)[11:08:54]{modules.c:200} Disabling module Dpms as its hard dep Xorg was disabled...
(D)[11:08:54]{modules.c:190} Dpms module disabled.
(D)[11:08:54]{modules.c:250} Dpms module destroyed.
(D)[11:08:54]{modules.c:250} Xorg module destroyed.
(D)[11:08:54]{modules.c:147} Trying to start Brightness module as its Bus dependency was loaded...
(D)[11:08:54]{modules.c:147} Trying to start Location module as its Bus dependency was loaded...
(D)[11:08:54]{modules.c:190} Location module disabled.
(D)[11:08:54]{modules.c:203} Trying to start Weather module as its Location soft dep was disabled...
(D)[11:08:54]{modules.c:250} Location module destroyed.
(D)[11:08:54]{modules.c:147} Trying to start Upower module as its Bus dependency was loaded...
(D)[11:08:54]{modules.c:59} Upower module started.
(D)[11:08:54]{modules.c:147} Trying to start Brightness module as its Upower dependency was loaded...
(D)[11:08:54]{modules.c:147} Trying to start Weather module as its Upower dependency was loaded...
(D)[11:08:54]{modules.c:147} Trying to start Network module as its Bus dependency was loaded...
(D)[11:08:54]{modules.c:59} Network module started.
(D)[11:08:54]{modules.c:147} Trying to start Weather module as its Network dependency was loaded...
(D)[11:08:54]{timer.c:34} Setted timeout of 0s 1ns on fd 6.
(D)[11:08:54]{modules.c:59} Weather module started.
(D)[11:08:54]{modules.c:68} Callback added for module Weather on module Upower bus match.
(D)[11:08:54]{modules.c:68} Callback added for module Weather on module Network bus match.
(I)[11:08:54]{weather.c:166} Weather cloudiness: 20.
(D)[11:08:54]{timer.c:34} Setted timeout of 10800s 0ns on fd 6.
(D)[11:08:54]{modules.c:147} Trying to start Brightness module as its Weather dependency was loaded...
(D)[11:08:54]{brightness.c:201} AC curve: y = -0.024825 + 0.191641x + -0.008928x^2
(D)[11:08:54]{brightness.c:201} BATT curve: y = -0.010629 + 0.153844x + -0.007284x^2
(D)[11:08:54]{timer.c:34} Setted timeout of 0s 1ns on fd 7.
(D)[11:08:54]{modules.c:59} Brightness module started.
(D)[11:08:54]{modules.c:68} Callback added for module Brightness on module Upower bus match.
(D)[11:08:55]{brightness.c:167} Average frames brightness: 0.547502.
(I)[11:08:55]{brightness.c:151} New brightness value: 2299
(D)[11:08:55]{timer.c:34} Setted timeout of 1200s 0ns on fd 7.

The status of clightd.service is running

systemctl status clightd.service
● clightd.service - Bus service to manage various screen related properties (gamma, dpms, backlight)
Loaded: loaded (/usr/lib/systemd/system/clightd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2018-02-13 11:08:54 CET; 13min ago
Main PID: 16465 (clightd)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/clightd.service
└─16465 /usr/lib/clightd/clightd
Feb 13 11:08:54 systemd[1]: Starting Bus service to manage various screen related properties (gamma, dpms, backlight)...
Feb 13 11:08:54 systemd[1]: Started Bus service to manage various screen related properties (gamma, dpms, backlight).
Feb 13 11:08:54 clightd[16465]: setting V4L2_CID_AUTOGAIN: Invalid argument

Valgrind errors in geoclue code.

Just running under valgrind without clightd running and clight not installed caused the following:

$ valgrind --track-origins=yes ./clight
==29667== Memcheck, a memory error detector
==29667== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29667== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==29667== Command: ./clight
==29667== 
Config file /etc/default/clight.conf not found.
Config file /home/arvid16/.config/clight.conf not found.
==29667== Invalid read of size 2
==29667==    at 0x4C33080: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1034)
==29667==    by 0x407AD2: call (bus.c:175)
==29667==    by 0x405400: geoclue_get_client (location.c:143)
==29667==    by 0x405270: geoclue_init (location.c:93)
==29667==    by 0x405006: init (location.c:33)
==29667==    by 0x40C5C4: init_modules (modules.c:24)
==29667==    by 0x40CE61: started_cb (modules.c:155)
==29667==    by 0x40CEDC: poll_cb (modules.c:170)
==29667==    by 0x404830: main_poll (main.c:109)
==29667==    by 0x404727: main (main.c:42)
==29667==  Address 0x7187d56 is 102 bytes inside a block of size 103 alloc'd
==29667==    at 0x4C3074F: realloc (vg_replace_malloc.c:826)
==29667==    by 0x40B038D: bus_socket_read_message (bus-socket.c:944)
==29667==    by 0x40BCD5E: bus_read_message.lto_priv.204 (sd-bus.c:1689)
==29667==    by 0x40BC9B6: sd_bus_call (sd-bus.c:2087)
==29667==    by 0x4079D5: call (bus.c:157)
==29667==    by 0x405400: geoclue_get_client (location.c:143)
==29667==    by 0x405270: geoclue_init (location.c:93)
==29667==    by 0x405006: init (location.c:33)
==29667==    by 0x40C5C4: init_modules (modules.c:24)
==29667==    by 0x40CE61: started_cb (modules.c:155)
==29667==    by 0x40CEDC: poll_cb (modules.c:170)
==29667==    by 0x404830: main_poll (main.c:109)
==29667== 
==29667== Invalid read of size 2
==29667==    at 0x4C3308E: memcpy@@GLIBC_2.14 (vg_replace_strmem.c:1034)
==29667==    by 0x407AD2: call (bus.c:175)
==29667==    by 0x405400: geoclue_get_client (location.c:143)
==29667==    by 0x405270: geoclue_init (location.c:93)
==29667==    by 0x405006: init (location.c:33)
==29667==    by 0x40C5C4: init_modules (modules.c:24)
==29667==    by 0x40CE61: started_cb (modules.c:155)
==29667==    by 0x40CEDC: poll_cb (modules.c:170)
==29667==    by 0x404830: main_poll (main.c:109)
==29667==    by 0x404727: main (main.c:42)
==29667==  Address 0x7187d58 is 1 bytes after a block of size 103 alloc'd
==29667==    at 0x4C3074F: realloc (vg_replace_malloc.c:826)
==29667==    by 0x40B038D: bus_socket_read_message (bus-socket.c:944)
==29667==    by 0x40BCD5E: bus_read_message.lto_priv.204 (sd-bus.c:1689)
==29667==    by 0x40BC9B6: sd_bus_call (sd-bus.c:2087)
==29667==    by 0x4079D5: call (bus.c:157)
==29667==    by 0x405400: geoclue_get_client (location.c:143)
==29667==    by 0x405270: geoclue_init (location.c:93)
==29667==    by 0x405006: init (location.c:33)
==29667==    by 0x40C5C4: init_modules (modules.c:24)
==29667==    by 0x40CE61: started_cb (modules.c:155)
==29667==    by 0x40CEDC: poll_cb (modules.c:170)
==29667==    by 0x404830: main_poll (main.c:109)
==29667== 
check_clightd_version(): The name org.clightd.clightd was not provided by any .service files
No clightd found. Clightd is a mandatory dep.
No functional module is running. Nothing to do...leaving.
==29667== 
==29667== HEAP SUMMARY:
==29667==     in use at exit: 8,192 bytes in 2 blocks
==29667==   total heap usage: 448 allocs, 446 frees, 94,220 bytes allocated
==29667== 
==29667== LEAK SUMMARY:
==29667==    definitely lost: 0 bytes in 0 blocks
==29667==    indirectly lost: 0 bytes in 0 blocks
==29667==      possibly lost: 0 bytes in 0 blocks
==29667==    still reachable: 8,192 bytes in 2 blocks
==29667==         suppressed: 0 bytes in 0 blocks
==29667== Rerun with --leak-check=full to see details of leaked memory
==29667== 
==29667== For counts of detected and suppressed errors, rerun with: -v
==29667== ERROR SUMMARY: 1566 errors from 2 contexts (suppressed: 0 from 0)

Device or resource busy

After updating clight-git to r524.c6c6af4-1 yesterday, it's not adjusting the brightness at startup. I'm using Manjaro GNOME now.

$ systemctl status clightd
● clightd.service - Bus service to manage various screen related properties (gamma, dpms, backlight)
   Loaded: loaded (/usr/lib/systemd/system/clightd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-02-13 07:58:13 MST; 1min 21s ago
 Main PID: 691 (clightd)
    Tasks: 1 (limit: 4915)
   Memory: 3.8M
   CGroup: /system.slice/clightd.service
           └─691 /usr/lib/clightd/clightd

Feb 13 07:58:13 paviliognome systemd[1]: Starting Bus service to manage various screen related properties (gamma, dpms, backlight)...
Feb 13 07:58:13 paviliognome systemd[1]: Started Bus service to manage various screen related properties (gamma, dpms, backlight).
Feb 13 07:58:52 paviliognome clightd[691]: setting V4L2_CID_AUTOGAIN: Invalid argument
Feb 13 07:58:53 paviliognome clightd[691]: (i2c_set_addr) Error in ioctl(I2C_SLAVE), errno=EBUSY(16): Device or resource busy
Feb 13 07:58:53 paviliognome clightd[691]: Registered Als sensor.
Feb 13 07:58:53 paviliognome clightd[691]: Registered Camera sensor.
Feb 13 07:58:53 paviliognome clightd[691]: [default]|DPMS|: New dpms timeouts:        Standby: 900s        Suspend: 1200s        Off:1800s.
Feb 13 07:58:53 paviliognome clightd[691]: [default]|SENSOR|: 5 frames captured by /dev/video0.
Feb 13 07:58:53 paviliognome clightd[691]: (i2c_set_addr) addr = 0x50. Returning EBUSY(-16): Device or resource busy
$ clight
Resource temporarily unavailable
A lock is present on /home/yochanan/.clight.log. Another clight instance running?

There's not much in the log:

(I)[07:58:52]{clightd.c:49}	Clightd found, version: 3.2.
(I)[07:58:52]{dpms.c:65}	Setted DPMS timeouts: Standby -> 900s, Suspend -> 1200s, Off -> 1800s.
(I)[07:58:54]{backlight.c:118}	Ambient brightness: 0.707 -> Backlight pct: 0.884
(I)[08:08:55]{backlight.c:118}	Ambient brightness: 0.809 -> Backlight pct: 0.941
(I)[08:12:56]{backlight.c:118}	Ambient brightness: 0.439 -> Backlight pct: 0.645

Add PC support.

clight.service - C daemon to adjust screen brightness to match ambient brightness, as computed capturing frames from webcam
   Loaded: loaded (/usr/lib/systemd/user/clight.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-04-06 02:28:36 MSK; 12s ago
 Main PID: 2711 (clight)
   CGroup: /user.slice/user-1000.slice/[email protected]/clight.service
           └─2711 /usr/bin/clight

But in /sys/class/backlight/ empty. This is normal for ati \ radeon, and im can set this if used
xrandr --output DVI-D-0 --brightness 0.8
can you add xrandr backend for change brightness ?

Support for brightness changes based off of ALS devices

It's very cool how Clight can use a webcam to detect ambient light levels, but some devices have an IIO ambient light sensor device, like the OPT3001.

It would be cool of Clight could use one of those to get the ambient light level instead of a webcam.

LKeeping an eye on the action

How can I check what clight is doing?
I can see the console output if I run it specifically in a command window, but if it is runnming in the background I can't see where it might be logging its actions..

Brightness after dim always 100%

Currently the clight always restores the dim state to 100% regardless the backlight level the screen had previously. Similarly if I set my backlight below the dim level, the brightness level raises up to the dim state level.

Would it be possible to store the pre-dim brightness level and then to restore it after dim? And also would be possible to not dim a screen at all when the current brightness level is below or equal the current brightness level ? Cheers.

Error when running clight

Hi, I ran into an error while running clight. The daemon does not start due to an unknown error.
$ systemctl --user start clight.service

$ systemctl --user status clight.service
● clight.service - C daemon to adjust screen brightness to match ambient brightness, as computed capturing frames from webcam
Loaded: loaded (/usr/lib/systemd/user/clight.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Tue 2017-04-18 19:48:09 +08; 1s ago
Process: 3925 ExecStart=/usr/bin/clight (code=exited, status=0/SUCCESS)
Process: 3922 ExecStartPre=/usr/bin/xhost + (code=exited, status=0/SUCCESS)
Main PID: 3925 (code=exited, status=0/SUCCESS)

$ clight
Failed to open lock.

It seems that the error message is not verbose enough. The below is my config

## Number of frames to be captured
frames = 7;

## Timeout between captures during the day
day_timeout = 100;

## Timeout between captures during the night
night_timeout = 500;

## Gamma daily temperature
day_temp = 6500;

## Gamma nightly temperature
night_temp = 4000;

## Uncomment to disable gamma smooth transitions
# no_smooth_gamma_transition = 1;

## Uncomment to disable gamma support
# no_gamma = 1;

## Your desired latitude for gamma support (surise/sunset in this location)
latitude = **<removed>**;

## Your desired longitude for gamma support (surise/sunset in this location)
longitude = **<removed>**;

## Video device to be used
video_devname = "/dev/video0";

## Screen syspath to be used
screen_sysname = "/sys/class/backlight/intel_backlight";

## Force set a sunrise time
# sunrise = "7:00";

## Force set a sunset time
# sunset = "19:00";

Kde Plasma - lower part of screen frozen

I have tried clight while using Plasma as DE but when I start it I got the lower part of the desktop blocked:

  • 3/4 of the screen are normal while 1/4 is like frozen

Clight freezes part of screen

When I run clight -c the bottom ~2/3 of my screen freeze (a sharp horizontal line separates the two areas). That is, the bottom part continues to display what has been there before and does not update anymore. The only way to solve this is a reboot (as far as I know). I'm on Arch Linux, using X and i3, everything fully updated.

Here's the output of clight -c --verbose:

% clight -c --verbose
Config file /home/julian/.config/clight.conf not found.
Signal module started.
Bus module started.
UserBus module being started as submodule of Bus...
UserBus module disabled.
Disabling module Inhibit as its hard dep UserBus was disabled...
Inhibit module disabled.
Trying to start Dimmer module as its Inhibit soft dep was disabled...
Inhibit module destroyed.
UserBus module destroyed.
Xorg module disabled.
Disabling module Gamma as its hard dep Xorg was disabled...
Gamma module disabled.
Trying to start Brightness module as its Gamma soft dep was disabled...
Location module disabled.
Location module destroyed.
Gamma module destroyed.
Disabling module Dimmer as its hard dep Xorg was disabled...
Dimmer module disabled.
Dimmer module destroyed.
Disabling module Dpms as its hard dep Xorg was disabled...
Dpms module disabled.
Dpms module destroyed.
Xorg module destroyed.
Clightd found, version: 2.2.
Clightd module started.
Trying to start Brightness module as its Clightd dependency was loaded...
Trying to start Brightness module as its Bus dependency was loaded...
Trying to start Upower module as its Bus dependency was loaded...
Upower module disabled.
Trying to start Brightness module as its Upower soft dep was disabled...
AC curve: y = -0.024825 + 0.191641x + -0.008928x^2
BATT curve: y = -0.010629 + 0.153844x + -0.007284x^2
Set timeout of 0s 1ns on fd 6.
Brightness module started.
Upower module destroyed.
Average frames brightness: 0.053657.
New brightness pct value: 0.075434
Brightness module destroyed.
Clightd module destroyed.
Bus module destroyed.
Signal module destroyed.

Any idea what could be up here? Thanks a lot for developing this very promising tool!

[FEATURE REQ] Different brightness for different monitors

I have a laptop (Thinkapd T480) with two external monitors connected: a Dell U2412M and an old Asus VW225 monitor. Currently when using clight, they end up at very different brightness levels (I suspect this is because they all have very different maximum brightness). In addition, the old Asus monitor can't handle too dark values (about 15% or lower) without starting to flicker (low PWM frequency).

Maybe I missed it, but there doesn't seem to be a way to set monitor-specific gamma curves and other settings. As an example, to be comfortable right now in a reasonably well lit room and of similar brightness I need the laptop monitor to be at about 40%, the Dell to be about 25% and the Asus at about 60%.

So for this to work I believe the ac_backlight_regression_points would have to be per monitor, preferably using some sort of monitor name (as opposed to connected output).

Turn off auto-calibration temporarily?

In older versions I can temporarily disable auto-calibration by:

systemctl --user stop clight.timer clight.service

In v3.0 there seems to be no graceful way to pause auto-calibration except killing the clight process... Am I missing something? Perhaps a new way to terminate / restart clight? Many thanks!

After SystemD suspend, time/values aren’t updated

Running clight as SystemD user service and clightd as normal SystemD service.

If I suspend(suspend to RAM) my workstation at night and e.g. the colortemperature is very warm. On the next morning when I resume my workstation the colortemperature isn’t updated, again with a warm colortemperature. So every resume at Daytime I have to restart the clight user service, that is my workaround at the moment.

Using clight on Arch Linux:
Version: efb0f9 - 2.5

Gamma location dependancy

Is there any reason not to have an option to treat gamma like backlight (color temp based on ambient light)?

can't build

I tried trunk, 2.1 and 1.4 versions, under lubuntu 16.04. I need it for i386 laptop (only 2Gb ram).
Installed build-essentials with *-dev packages, mentioned in build deps, in README.md:
libsystemd-dev, libpopt-dev, libgsl-dev, libconfig-dev.
There is gcc-5.3 used (probably not best, at least gentoo was 5.4.0, right after 4.9.4, before 6.4.0.

Build log:

$ LANG=C make
fatal: Not a git repository (or any parent up to mount point /home/margo)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
brightness.c: In function 'callback':
brightness.c:57:5: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
     read(main_p[self.idx].fd, &t, sizeof(uint64_t));
     ^
dimmer.c: In function 'callback':
dimmer.c:77:9: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
         read(main_p[self.idx].fd, &t, sizeof(uint64_t));
         ^
gamma.c: In function 'callback':
gamma.c:48:5: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result]
     read(main_p[self.idx].fd, &t, sizeof(uint64_t));
     ^
location.c: In function 'load_cache_location':
location.c:73:9: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
         fscanf(f, "%lf %lf", &conf.loc.lat, &conf.loc.lon);
         ^
In file included from /usr/include/fcntl.h:289:0,
                 from /usr/include/i386-linux-gnu/sys/file.h:24,
                 from lock.c:2:
In function 'open',
    inlined from 'gain_lck' at lock.c:13:14:
/usr/include/i386-linux-gnu/bits/fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
    __open_missing_mode ();
    ^
makefile:42: recipe for target 'objects' failed
make: *** [objects] Error 1

(make deb doesn't go different, as it needs to build anyway)

Clight is failing to start on Ubuntu 16.04

Steps to reproduce:

  1. Enable clightd systemctl service:
    $ sudo systemctl enable clightd.service
    $ sudo systemctl start clightd.service

  2. Try to start clight from command line:
    $ clight
    Config file /home/mate/.config/clight.conf not found.
    Bus support started.
    Message recipient disconnected from message bus without replying
    Bus destroyed.

  3. Or try to start with systemctl
    $ systemctl --user start clight.service

So clightd service just doesn't want to start

Logs:

Systemctl: https://pastebin.com/X5dKjzSS
journalctl: https://pastebin.com/5Y6vHt1p

screen light

On laptops with poorly placed webcams the screen and keyboard back-lights can fool clight into believing that the ambient light level is higher than it is.

CMake Error

Manjaro Linux
pamac 7.3.0-5
clight-git AUR package

Building clight-git...
==> Making package: clight-git r488.59886b0-1 (Sat 24 Nov 2018 08:35:53 AM MST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating Clight git repo...
Fetching origin
==> Validating source files with sha256sums...
    Clight ... Skipped
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Creating working copy of Clight git repo...
Cloning into 'Clight'...
done.
==> Starting prepare()...
==> Starting pkgver()...
==> Starting build()...
-- The C compiler identification is GNU 8.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.5.4") 
-- Checking for modules 'popt;gsl;libconfig'
--   Found popt, version 1.16
--   Found gsl, version 2.5
--   Found libconfig, version 1.7.2
-- Checking for one of the modules 'libelogind;libsystemd>=221'
CMake Error at CMakeLists.txt:84 (install):
  install FILES given no DESTINATION!


-- Configuring incomplete, errors occurred!
See also "/tmp/makepkg/clight-git/src/Clight/build/CMakeFiles/CMakeOutput.log".
==> ERROR: A failure occurred in build().
    Aborting...

CMakeOutput.log

I also tried building with the updated PKGBUILD from your master branch with no difference.

Systemd service does not start (Ubuntu 17.04)

I enabled the service via systemctl --user enable clight.service however after reboot, systemctl --user status clight.service results in

``
clight.service - C daemon to adjust screen brightness to match ambient brightn
Loaded: loaded (/usr/lib/systemd/user/clight.service; enabled; vendor preset:
Active: failed (Result: exit-code) since Tue 2017-04-18 11:23:07 CEST; 13min

Apr 18 11:23:07 Surface-Pro-3 systemd[1623]: Starting C daemon to adjust screen
Apr 18 11:23:07 Surface-Pro-3 systemd[1623]: clight.service: Control process exi
Apr 18 11:23:07 Surface-Pro-3 systemd[1623]: Failed to start C daemon to adjust
Apr 18 11:23:07 Surface-Pro-3 systemd[1623]: clight.service: Unit entered failed
Apr 18 11:23:07 Surface-Pro-3 systemd[1623]: clight.service: Failed with result
Apr 18 11:23:08 Surface-Pro-3 systemd[1623]: [/usr/lib/systemd/user/clight.servi
Apr 18 11:23:08 Surface-Pro-3 systemd[1623]: [/usr/lib/systemd/user/clight.servi

``

Starting the service manually via systemctl --user start clight.service turns clight on and everything seems to work.

Wrong behavior with brightness

EDIT: i did not test it enough.
Brightness changes automatically after start even if all modules are unloaded, with message:
New brightness pct value: 0.014719
this value is never same, and seems to be randomly selected from some range, but it doesn't depend on current brightness.

Support keyboard backlit

Some laptops such as Asus or Lenovo have keyboard backlight. It'd be great to enable it with very dark ambient light.

clight doesn't find dependencies [Ubuntu 18.04]

I just came across clight and was excited to try it out on Ubuntu 18.04 LTS but it seems like it runs into an error when trying to start up. In case it matters, this is a fresh Ubuntu 18.04 install with all of the dependencies for clight installed via a combination of apt and dpkg. It looks like the install of clight completes just fine, as I noticed it in the Ubuntu applications menu; however, I didn't notice it having any effect. Also, I mainly use i3 and am not sure that clight is even starting properly in this setting (I didn't try to start it from my i3 config).

When just trying to invoke clight, I get the following (even though libconfig9 is installed properly):

❯ clight
clight: error while loading shared libraries: libconfig.so.11: cannot open shared object file: No such file or directory

I'm assuming that there's something odd going on with finding dependencies based on this SO comment and related posts.

Has anyone run into a similar problem on Ubuntu systems? Any help would be much appreciated.

clight hangs on no network connection

As said on the Arch boards, I found a way to test (a sock over the webcam, works great :P )

Anyway, when running clight without a network connection and no defined location, it hangs on I assume getting the location. You might want to check for a network connection and maybe define a backup location in the config.
clight.txt

Config to set absolute minimum brightness

Please add a config to let users choose minimum/maximum brigtness instead of just 0 and detected maximum value. Some laptops (a.k.a. mine) completely shuts LCD down when they are told to set brightness to 0, causing really (a lot!) troubles.

It would be ideal to be able to set valued used for interpolating, but just clamp would be okay.

Gamma correction is backwards in southern hemisphere.

Hey as my other report. Putting my conf file like this:
gamma_temp = [ 5900, 3800 ]
Results in my daytime gamma being set at 3800.
Settng it like this:
gamma_temp = [ 3800, 5900 ]
Has it set correctly working as expected. lat long set as follows:

 latitude = -31.4823342;
longitude = 118.281299; ```

Build fails due to `floating constant in preprocessor expression`

In Debian testing. Installed all dependencies, and passed cmake ... But now when I do make, I am getting

[  4%] Building C object CMakeFiles/clight.dir/src/modules/bus.c.o
/home/hyiltiz/src/Clight/src/modules/bus.c: In function ‘call’:
<command-line>: error: floating constant in preprocessor expression
/home/hyiltiz/src/Clight/src/modules/bus.c:103:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’
 #if LIBSYSTEMD_VERSION >= 234
     ^~~~~~~~~~~~~~~~~~
/home/hyiltiz/src/Clight/src/modules/bus.c: In function ‘add_match’:
<command-line>: error: floating constant in preprocessor expression
/home/hyiltiz/src/Clight/src/modules/bus.c:203:5: note: in expansion of macro ‘LIBSYSTEMD_VERSION’
 #if LIBSYSTEMD_VERSION >= 237
     ^~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/clight.dir/build.make:128: CMakeFiles/clight.dir/src/modules/bus.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/clight.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Trying to build under Fedora 29

cmake fails with

-- Checking for modules 'popt;gsl;libconfig'
--   Package 'popt', required by 'virtual:world', not found
--   Package 'gsl', required by 'virtual:world', not found
--   Package 'libconfig', required by 'virtual:world', not found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:436 (message):
  A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPkgConfig.cmake:602 (_pkg_check_modules_internal)
  CMakeLists.txt:35 (pkg_check_modules)

Yet I do have all those modules:

#rpm -qa | grep -P '(popt|gsl|libconfig)'
libconfig-1.7.2-2.fc29.x86_64
popt-1.16-15.fc29.x86_64
gsl-2.4-7.fc29.x86_64

Clight argument sunset not updated

by executing as user:
/usr/bin/clight --sunset=22:00 the sunset argument doesn't change the sunset time, my screen will shift to red when the sun goes down at 20:00.

how can I avoid the red shifting at 20:00?

Under Fedora 29 - Still not runnjing in background from startup

The logs show that the intial startup fails as follows;

(W)[06:43:05]{bus.c:309}	check_clightd_version(): Connection timed out
(W)[06:43:05]{clightd.c:42}	No clightd found. Clightd is a mandatory dep.
(E)[06:43:05]{modules.c:242}	No functional module is running. Nothing to do...leaving.

This shows it (and clightd) running:


 brianr  ~  ps ax | grep clight
 2208 ?        S      0:00 clight
 2833 ?        Ss     0:00 /usr/lib/clightd/clightd
 2971 pts/0    S+     0:00 grep --color=auto clight
 brianr  ~  ps ax | grep clight
 2833 ?        Ss     0:00 /usr/lib/clightd/clightd
 3079 pts/0    S+     0:00 grep --color=auto clight
 brianr  ~  

Maybe a timing problem?

I get a dialog to allow access to geolocation. - is that effecting the timing of things?

If I then run clight from the command line, things seem to work:

 brianr  ~  clight
Clightd found, version: 3.4.
Setted DPMS timeouts: Standby -> 900s, Suspend -> 1200s, Off -> 1800s.
inhibit_check(): The name org.freedesktop.PowerManagement.Inhibit was not provided by any .service files
PowerManagement inhibition appears to be unsupported.
Location XX.XX YY.YY loaded from cache file!
6500 gamma temp set.
Next gamma alarm due to: Thu Mar 21 HH:MM:SS 2019
init_kbd_backlight(): No such interface “org.freedesktop.UPower.KbdBacklight” on object at path /org/freedesktop/UPower/KbdBacklight
Keyboard backlight calibration unsupported.
Ambient brightness: 0.218 -> Backlight pct: 0.350

Location not caching

When booting my laptop when not connected to the internet, Clight does not remember the last location it acquired when online. I'm not sure if it's an issue with it not caching to begin with or not being able to load it from the cache.

I think it may only happen when there was no internet connection when I shutdown and no internet connection when booting up again.

(W)[08:16:04]{bus.c:308}	geoclue_get_client(): Failed to activate service 'org.freedesktop.GeoClue2': timed out (service_start_timeout=25000ms)
(W)[08:16:04]{location.c:107}	Geoclue2 appears to be unsupported.
(I)[08:16:04]{location.c:73}	Location 0.00 0.00 loaded from cache file!
(W)[08:16:04]{modules.c:89}	Error while loading LOCATION module.

Manjaro Linux Cinnamon
clight 3.1-2
clightd 3.1-1

Allow light correction with configfile

For me default clight settings are to bright. I would prefer to have way to correct settings.
i.e. right now clights sets brightness 3600 for me, but I would prefer 2200.

Wrong number of ...

Uncomment ac_capture_timeouts, batt_capture_timeouts, gamma_temp config options, clight says:

Wrong number of ac_capture_timeouts array elements.
Wrong number of batt_capture_timeouts array elements.
Wrong number of gamma_temp array elements.

Clight version: 3.1

clight too much cpu usage

Hi, clight too much cpu usage (After turning on the computer)
When I close the program and run it again, the problem is resolved
The version of the package I installed:
clight-git r503.9463fcd-1
clightd-git r206.f6c5c46-1

OS: Manjaro Linux x86_64
Kernel: 4.19.4-1-MANJARO
Resolution: 1360x768
DE: KDE
WM: KWin
CPU: Pentium E5700 (2) @ 3.000GHz
GPU: Intel 4 Series Chipset
Memory: 1249MiB / 3908MiB

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
789 neoman 20 21560 3488 3144 R 99.7 0.1 2:30.78 /bin/clight
731 neoman 20 1376668 192780 99804 S 8.3 4.8 0:18.62 /bin/plasmashell

neo ~ clight Clightd found, version: 3.0. Setted DPMS timeouts: Standby -> 900s, Suspend -> 1200s, Off -> 1800s. 6500 gamma temp set. Next gamma alarm due to: Fri Dec 7 18:30:00 2018 init_kbd_backlight(): No such interface “org.freedesktop.UPower.KbdBacklight” on object at path /org/freedesktop/UPower/KbdBacklight Keyboard backlight calibration unsupported. Ambient brightness: 0.414 -> Backlight pct: 0.616

`####################

Clight conf file

####################

############

TIMEOUTS

############

Timeouts between captures during day/night/event on AC

ac_capture_timeouts = [ 60, 60, 60 ];

Timeouts between captures during day/night/event on BATT

batt_capture_timeouts = [ 1200, 5400, 600 ];

Dimmer timeouts on AC/on BATT.

Set any of these to <= 0 to disable dimmer

in the corresponding AC state.

dimmer_timeouts = [ 45, 20 ];

Timeouts for dpms on AC

Set any of these to <= 0 to disable dpms on AC

ac_dpms_timeouts = [ 900, 1200, 1800 ];

Timeout for dpms on BATT

Set any of these to <= 0 to disable dpms on BATT

batt_dpms_timeouts = [ 300, 420, 600 ];

#########

GAMMA

#########

Gamma temperature during day and night

gamma_temp = [ 6500, 4000 ]

###################

DISABLE MODULES

###################

Uncomment to disable brightness support

no_brightness = 1;

Uncomment to disable gamma support

no_gamma = 1;

Uncomment to disable dpms tool

no_dpms = 1;

Uncomment to disable org.freedesktop.PowerManagement.Inhibit

interface support

no_inhibit = 1;

Uncomment to disable dimmer tool

no_dimmer = 1;

##################

SMOOTH OPTIONS

##################

Uncomment to disable backlight smooth transitions

no_smooth_backlight_transition = 1;

Uncomment to disable gamma smooth transitions

no_smooth_gamma_transition = 1;

Uncomment to disable dimmer smooth transitions

no_smooth_dimmer_transition = 1;

Backlight transition step in percentage

backlight_trans_step = 0.05;

Backlight transition step

gamma_trans_step = 50;

Dimmer transition step in percentage

dimmer_trans_step = 0.05;

Backlight transition timeout in ms

backlight_trans_timeout = 30;

Backlight transition timeout in ms

gamma_trans_timeout = 300;

Dimmer transition timeout in ms

dimmer_trans_timeout = 30;

####################

BACKLIGHT CURVES

####################

Y points used to compute ambient_brightness while ON AC -> screen backlight curve best-fit parameters

through polynomial regression. X values are simply array's indexes (from 0 to 10 included).

ac_brightness_regression_points = [ 0.0, 0.0, 0.20, 0.70, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ];
#ac_brightness_regression_points = [ 0.0, 0.15, 0.29, 0.45, 0.61, 0.74, 0.81, 0.88, 0.93, 0.97, 1.0 ];

Y points used to compute ambient_brightness while ON BATTERY -> screen backlight curve best-fit parameters

through polynomial regression. X values are simply array's indexes (from 0 to 10 included).

#batt_brightness_regression_points = [ 0.0, 0.15, 0.23, 0.36, 0.52, 0.59, 0.65, 0.71, 0.75, 0.78, 0.80 ];

###########

GENERIC

###########

Number of frames to be captured

frames = 5;

Your desired latitude for gamma support (surise/sunset in this location)

latitude = 38.4;

Your desired longitude for gamma support (surise/sunset in this location)

longitude = 48.4;

Video device to be used (only last part of syspath)

video_devname = "video0";

Screen syspath to be used (only last part of syspath)

screen_sysname = "intel_backlight";

Force set a sunrise time

sunrise = "7:00";

Force set a sunset time

sunset = "19:00";

Duration of an "event". Clight will enter "event" mode (more frequent screen recalibrations)

from event_duration seconds before a sunrise/sunset, until event_duration seconds after.

event_duration = 1800

Change dimmer backlight level, in percentage

dimmer_pct = 0.2;

Verbose mode, useful in case of bugs:

run clight in verbose mode,

then open issue on github attaching log

verbose = 1;
`

missing clight.service

After building from source, running the calibration desktop file results in a clight.service not found error.
systemctl and find are both unaware of such a file.

Handle webcam shutters

Webcam shutters are common nowadays, especially on the new Lenovo laptops with their ThinkShutter. With a shutter put on, clightd would detect a very dark ambient light and then wrongly adjust the brightness. This can be frustrating to workaround.

Here's what I get in normal use, shutter off:

$ busctl call org.clightd.clightd /org/clightd/clightd/Sensor org.clightd.clightd.Sensor Capture "si" "" 5
sad "/dev/video0" 5 0.367066 0.367066 0.367066 0.367066 0.367066

And here's what I get with the shutter on:

$ busctl call org.clightd.clightd /org/clightd/clightd/Sensor org.clightd.clightd.Sensor Capture "si" "" 5
sad "/dev/video0" 5 0.0745098 0.0745098 0.0745098 0.0745098 0.0745098

I don't think it makes much sense to consider a brightness value being this low as very dark room, because the screen will always provide some light, unless you're in the dark with your screen completely powered off, which a corner case ;-)

Here's my suggestion:

clightd can consider a threshold under which it will ignore the captures and log a message eventually. The package can ship with a default sensible value (e.g. 0.09) which would cover most setup (since clightd intends to be zero-conf). Users can override the threshold, setting it to 0 would naturally disable this behavior.

Would this make sense?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.