Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Ambient light sensor to dynamically adjust screen brightness
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
alogim
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2015
Posts: 95

PostPosted: Fri Oct 05, 2018 7:40 am    Post subject: Ambient light sensor to dynamically adjust screen brightness Reply with quote

Good morning everyone. I am a (sofar) happy owner of an HP EliteBook 850 G5. Now, this laptop comes with an in-built ambient light sensor on the top of the screen. When I tried the Ubuntu live, it used to work smoothly (whenever the ambient light changed, the screen brightness changed as well).
I would like to be able to get this on Gentoo as well, taking into account the fact that I am currently using Xfce4.

I can see the sensor listed under /sys/bus/iio/devices and under /dev:
Code:

➜  / ls /sys/bus/iio/devices
iio:device0  trigger0

➜  / ls /dev | grep iio
iio:device0
If I enter directory iio:device0, I can see the following:
Code:
➜  iio:device0 ls
buffer  in_illuminance_hysteresis  in_illuminance_raw                 in_illuminance_scale   in_intensity_hysteresis  in_intensity_sampling_frequency  name   scan_elements  trigger
dev     in_illuminance_offset      in_illuminance_sampling_frequency  in_intensity_both_raw  in_intensity_offset      in_intensity_scale               power  subsystem      uevent

Is there a way I can write some kind of utility to manage brightness according to the values available there? Could anyone help me with this?
_________________
Desktop: i5-3570k - 2x4 GB - Sapphire HD 7950 Dual-X - 500 GB WD Caviar Black - Dell SE2717H 27"
Laptop: HP EliteBook 850 G5 - i7-8550U - 1x16GB - Intel UHD 620 - 512 GB Samsung NVMe SSD
Phone: OnePlus 5T - SD835 - 8 GB - Adreno 540 - 128 GB
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1561
Location: United Kingdom

PostPosted: Fri Oct 05, 2018 10:26 am    Post subject: Reply with quote

There is a kernel module hp-wmi for controlling various things in HP laptops, including the ambient light sensor. If it is not already configured in your kernel, you could configure it (CONFIG_HP_WMI=m) and load the module to see if that works ('modprobe hp-wmi' then 'echo 1 > /sys/devices/platform/hp-wmi/als' to enable the ALS). But, as you say it is working in Ubuntu, before you reconfigure and rebuild your kernel in Gentoo I suggest you boot an Ubuntu LiveCD or LivePendrive to check whether or not the hp-wmi module is loaded in Ubuntu ('lsmod').
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1561
Location: United Kingdom

PostPosted: Fri Oct 05, 2018 11:26 am    Post subject: Reply with quote

If the hp-wmi module does not solve your problem, then the tool iio-sensor-proxy might. However, it has a hard dependency on systemd (see the Gentoo Forums thread iio-proxy for sensors and the Gentoo ebuild app-misc/iio-sensor-proxy in the mva overlay), so if you're not using systemd you could try in a local overlay the iio-sensor-proxy ebuild developed by Funtoo, as the Funtoo developers have excised the systemd dependency (see iio-sensor-proxy requires that "s" word - should I keep trying or move on? and Funtoo LinuxFL-4265 -- ii-sensor-proxy ebuild request).
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
alogim
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2015
Posts: 95

PostPosted: Fri Oct 05, 2018 11:44 am    Post subject: Reply with quote

Fitzcarraldo wrote:
There is a kernel module hp-wmi for controlling various things in HP laptops, including the ambient light sensor. If it is not already configured in your kernel, you could configure it (CONFIG_HP_WMI=m) and load the module to see if that works ('modprobe hp-wmi' then 'echo 1 > /sys/devices/platform/hp-wmi/als' to enable the ALS). But, as you say it is working in Ubuntu, before you reconfigure and rebuild your kernel in Gentoo I suggest you boot an Ubuntu LiveCD or LivePendrive to check whether or not the hp-wmi module is loaded in Ubuntu ('lsmod').

I forgot to say that I wrote down all modules used by Ubuntu as well, so I enabled hp_wmi in the kernel right when I installed it. I also had to enable ACPI_ALS and HID_SENSOR_ALS.
If I try to echo 1 on that file (which exists), I get the following error:
Code:
bash: echo: write error: Invalid argument
If I try to open the file with nano, I get
Code:
[ magic_file(als) failed: cannot read `als' (Invalid argument) ]

_________________
Desktop: i5-3570k - 2x4 GB - Sapphire HD 7950 Dual-X - 500 GB WD Caviar Black - Dell SE2717H 27"
Laptop: HP EliteBook 850 G5 - i7-8550U - 1x16GB - Intel UHD 620 - 512 GB Samsung NVMe SSD
Phone: OnePlus 5T - SD835 - 8 GB - Adreno 540 - 128 GB
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum