FedeDP / Clightd

A linux bus interface that lets you change screen brightness, compute captured webcam frames brightness and change screen temperature.
GNU General Public License v3.0
83 stars 10 forks source link

Not working on archlinux Intel Skylake #4

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hey the clight -c works and it gives an output. I set conf settings for Gamma just to make sure it was activated, but after a few days I'm sure its not working. I have tried to play with it and issue 'getgamma' or 'setgamma' but the examples are just not detailed enough for me. This looks like the tool I want as xbacklight is incompatible with my thinkpad p50.

I tried to check the log file but it was only generated once, I cleared it away and rebooted a heap of times and it has not returned. I installed via AUR and it compiled with all optionals without worry. I tried isseing systemctl --user status calls but it only returns: +Failed to connect to bus: No such file or directory.

ghost commented 6 years ago

[blackjok3r@adamp50 ~]$ clight -c --verbose 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.0. 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 Setted timeout of 0s 1ns on fd 6. Brightness module started. Upower module destroyed. Average frames brightness: 0.332834. New brightness pct value: 0.514121 Brightness module destroyed. Clightd module destroyed. Bus module destroyed. Signal module destroyed.

ghost commented 6 years ago

Issued a manual compile from this git: $ make Frames capturing support enabled. Gamma support enabled. DPMS support enabled. idle support enabled. DDCutil support enabled.

ghost commented 6 years ago

Ran clight -c --verbose again

[blackjok3r@adamp50 ~]$ clight -c --verbose 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.0. 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 Setted timeout of 0s 1ns on fd 6. Brightness module started. Upower module destroyed. Average frames brightness: 0.280710. New brightness pct value: 0.442781 Brightness module destroyed. Clightd module destroyed. Bus module destroyed. Signal module destroyed.

Apr 25 20:43:13 adamp50 dbus-daemon[350]: [system] Successfully activated service 'org.clightd.backlight'

FedeDP commented 6 years ago

Hi! Thanks for taking the time to report your issue.
Your clight's log looks fine.
To be honest, I could not really understand what is the issue you are experiencing. Is it gamma correction not working? Or backlight?

ghost commented 6 years ago

Oh sorry, should have been more clear. Is not doing gamma correction and I couldn't work out the api to try and set things manually to check. I'm pretty sure the webcam is not doing auto correction either as it only seems to turn on when I run clight-c manually.

FedeDP commented 6 years ago

I think that clight service is not running; from your output above:

I tried isseing systemctl --user status calls but it only returns: +Failed to connect to bus: No such file or directory.

It seems you haven't got a systemd user session properly setted.
You can try to run "clight" (without "-c") from commandline and see if that properly works.
When you run clight -c you should only see your backlight changing; indeed gamma is disabled (clight -c only performs backlight correction and exits).

For gamma, you can try busctl call org.clightd.backlight /org/clightd/backlight org.clightd.backlight setgamma "ssi(buu)" ":0" "$HOME/.Xauthority" "4500" 0 0 0

ghost commented 6 years ago

I reinstalled it and issuing clight from command line, gives permission denied as expected as its already running? Is there a way to lof what the deamon is actually trying to do? I edited my home folder conf file and removed the space's before my lat/long values and the gamma line, pretty sure this won't do anything but worth a try. Using the busctl call you gave changes gamma as expected. How can I check that the clight deamon is actually being called every 30mins to change backlight and gamma?

FedeDP commented 6 years ago

You should have a $HOME/.clight.log log file :) Monitor it and you should see it running.
Since it gave you permission denied, it means clight is already running.
Paste here your logfile too, if you wish!

Just out of curiosity, mind to paste output of: systemctl --user status clight.service too?
Thank you!

ghost commented 6 years ago

● clight.service - C daemon to adjust screen brightness to match ambient brightness, as computed capturing frames f> Loaded: loaded (/usr/lib/systemd/user/clight.service; disabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2018-04-26 17:33:58 AWST; 2s ago Process: 29407 ExecStart=/usr/bin/clight (code=exited, status=1/FAILURE) Main PID: 29407 (code=exited, status=1/FAILURE)

Apr 26 17:33:58 adamp50 systemd[508]: clight.service: Main process exited, code=exited, status=1/FAILURE Apr 26 17:33:58 adamp50 systemd[508]: clight.service: Failed with result 'exit-code'. There is no .clight.log in my home dir.

FedeDP commented 6 years ago

Wow this is weird!
It seems more of an issue with clight than clightd though, but let's continue on this thread anyway.
I'd say that clight crashed after creating the lock file in your home (preventing any other clight session to start) and before creating the log file; and this is super-weird.

You can try to manually remove $HOME/.clight.lock file and then start clight from a terminal and check its output.
Paste it here please :)

ghost commented 6 years ago

Thanks! That was it. Finally it seems to be working. I think. clight --verbose Signal module started. Bus module started. UserBus module being started as submodule of Bus... UserBus module started. 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 Inhibit module as its Xorg dependency was loaded... Connection timed out Xorg module destroyed. UserBus module destroyed. Bus module destroyed. Signal module destroyed.

The service now starts also. I will monitor he log and see if it is indeed working as intended. Thanks a lot for the help. And this is a great tool, more people should use it.

FedeDP commented 6 years ago

Unfortunately you still seem to have some weird issues:

Connection timed out Xorg module destroyed. UserBus module destroyed. Bus module destroyed. Signal module destroyed.

Surely right after this, clight exits...
I don't understand why your bus is acting like this; it isn't an issue with clight/clightd itself but with your bus session. That "Connection timed out" is a bus response.

EDIT: What'y your DE?

ghost commented 6 years ago

I made sure redshift was disabled, and rebooted and ran clight --verbose again and got this, a litle diffrent but it did eventually exit. Seems the service also isn't starting on reboot, might just be set to disable though. I am using i3 with a xfce4 panel. But I used some other guys install script and I'm starting to think I shouldn't have tried to take shortcuts. He might have something in here causing troubles with stuff Signal module started. Bus module started. UserBus module being started as submodule of Bus... UserBus module started. 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 Inhibit module as its Xorg dependency was loaded... Clightd found, version: 2.0. Clightd module started. Trying to start Brightness 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... 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. Trying to start Gamma module as its Location soft dep was disabled... Location module destroyed. Trying to start Upower module as its Bus dependency was loaded... Upower module started. Trying to start Brightness 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 Gamma module as its Bus dependency was loaded... Setted timeout of 0s 1ns on fd 7. Gamma module started. Trying to start Dimmer module as its Bus dependency was loaded... Trying to start Dpms module as its Bus dependency was loaded... Dpms module started. Callback added for module Dpms on module Upower bus match. Callback added for module Dpms on module Upower bus match. Connection timed out Dpms module destroyed. Gamma module destroyed. Upower module destroyed. Clightd module destroyed. Xorg module destroyed. UserBus module destroyed. Bus module destroyed. Signal module destroyed.

ghost commented 6 years ago

Yes the deamon still crashes out when starting the service too. :(

FedeDP commented 6 years ago

Well this output seems correct now!
Clight is not auto-starting on boot because i3 is not xdg-compliant, and it will not autostart desktop file placed in /etc/xdg/autostart.
You should manually add "systemctl --user start clight.timer" to your session manager script (where you autostart all your programs, like xfce4-panel).

EDIT: What do you mean with "eventually exits"? Care to share log part where it leaves?

FedeDP commented 6 years ago

Yes the deamon still crashes out when starting the service too. :(

What do you mean with crashes?

ghost commented 6 years ago

I don't understand what its doing lol. If clight hasnt been started before I can issue bus calls with the command you gave me. But once I have started clight every time it tries to access the clightd it just times out. What is the clightd service so i can check that?

FedeDP commented 6 years ago

Clightd service is the system bus that provides functions that should be run as root (like changing backlight level).
Can you try to disable clight systemd user service, reboot and run it manually from cmdline (clight --verbose), and paste it all the output after 30''?
I don't get what is going on here...

ghost commented 6 years ago

Ok playing around with it. On a fresh reboot, I can issue gamma calls as much as I like with the call you gave me. But as soon as I run clight once, that eventually stops. I have tried disabling DPMS and Upower via commandline and no go.

$ clight --no-inhibit --verbose Signal module started. Bus module started. UserBus module being started as submodule of Bus... UserBus module started. 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... Inhibit module disabled. Trying to start Dimmer module as its Inhibit soft dep was disabled... UserBus module disabled. UserBus module destroyed. Inhibit module destroyed. Clightd found, version: 2.0. Clightd module started. Trying to start Brightness 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... 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. Trying to start Gamma module as its Location soft dep was disabled... Location module destroyed. Trying to start Upower module as its Bus dependency was loaded... Upower module started. Trying to start Brightness 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 Gamma module as its Bus dependency was loaded... Setted timeout of 0s 1ns on fd 6. Gamma module started. Trying to start Dimmer module as its Bus dependency was loaded... Trying to start Dpms module as its Bus dependency was loaded... Dpms module started. Callback added for module Dpms on module Upower bus match. Connection timed out Dpms module destroyed. Gamma module destroyed. Upower module destroyed. Clightd module destroyed. Xorg module destroyed. Bus module destroyed. Signal module destroyed.

FedeDP commented 6 years ago

So, there is something killing your bus session as soon as clight starts. Well, not immediately though: it gets destroyed right after starting dpms module.

What happens when you try to call again busctl command to change gamma? It gives an error after staying "freezed" for quite some time?

ghost commented 6 years ago

Once clight has been started one time, I can no longer issue bus calls. It just waits and times out, then on reboot it waits 1:30 for the process to stop. Can I compile both without dpms and upower and try that? Not so good with makefiles etc yet, looking at it but it makes little sense lol. Thanks very much for taking the time to help me.

FedeDP commented 6 years ago

Mmh i may be able to reproduce the issue if this holds true:

It gives "connection timed out" after staying "freezed" for quite some time?

FedeDP commented 6 years ago

Ok, then the issue is with the getgamma clightd call. I will try to fix it as soon as i am home.
Another problem is that i am not able to reproduce the issue on my home pc; so i will probably ask you to test :) (i can only reproduce this on my work pc).
Really thanks for helping me find out this issue!

ghost commented 6 years ago

No worries. Is there a way to issue gdb backtrace on clightd?

ghost commented 6 years ago

Does it have a pid?

FedeDP commented 6 years ago

It is not crashing.
I guess it gets into a weird loop causing bus to raise a timeout error.

ghost commented 6 years ago

confirmed, I have 1 core maxing out at 100% and clightd wont pkill -15. pkill -9, stops it fine. It restarts without issue, and when I enter, busctl call org.clightd.backlight /org/clightd/backlight org.clightd.backlight getgamma "ss" ":0" "$HOME/.Xauthority"

It maxes the CPU again.

FedeDP commented 6 years ago

Yes, it is surely caused by the get_gamma function: it probably cannot find a good enough approximation for your screen temperature so it loops forever.
I will try to fix it asap!
Again, really thank you for all your time spent debugging!

ghost commented 6 years ago

Its my job at the moment and this s teaching me valuable stuff so thank you. :)

FedeDP commented 6 years ago

This should be fixed now :)
Thanks for your kind testing!
Let me know if you encounter any other issue or if you have any feedback/feature request!
By the way, please update clight too (build both clight-git and clightd-git aur packages!).

ghost commented 6 years ago

Hey seems to be working fine now, is there a way to manually call a gamma readjustment? Its defiantly choosing the wrong value. I have lat and long set in conf file and its setting 3800 gamma at 11:30am. Is this a normal thing? I ran the manual gamma adjustment to 5900 and my screen is much brighter. I will try a system reboot to test the clight deamon is auto starting and see what it settles on next time.

ghost commented 6 years ago

Hey, I fixed the gamma issue by putting the night time value in the conf first. I will see what happens at night time and if it changes over as expected. I guess this might be to do with having a -ve latitude?

FedeDP commented 6 years ago

I guess this might be to do with having a -ve latitude?

It can be. Anyway, sounds like a bug to me :)
Mind to open an issue on clight to track this down?