Everything is written in bash... and it is my first bash-script so it might not be super-pretty, but it works :-D
::: Installation :::
There are two ways:
The manual way
(pick _gmux or _intel accordinlgy)
1) Copy ambientLightFix to /usr/bin/
2) Copy ambientLightFix.service to /etc/systemd/system/
3) $
systemctl enable ambientLightFix_intel.service --now
The automated way
(will also help you uninstall or update to a newer version as well as check if you have ambience sensors before attempting setup)
1) Run
AmbientLightFix_RunME.sh
in a Terminal and state your password a couple of times when prompted.Hope my little program will give you many happy hours in front of your screen :-)
Ratings & Comments
29 Comments
I just discovered that the ambient light sensor device is dynamic instead of static. If someone can answer these questions for me, there may be a way to get this script working again: https://www.reddit.com/r/linuxquestions/comments/1iwhw3o/need_help_with_iio_sensors/
Hi there. It's been super-long since last I did anything with my script, nice that it still can spread some joy... Or well, provided that we can fix your issue :-D So let me get this straight; you get different numbers added to your /sys/bus/iio/devices/iio:device each time you boot up? What distro are you on? Are you dual booting?
The device numbers for iio devices are assigned dynamically, so they change for each device on each boot. This changes the location of the directory for in_illuminance_raw. For example, on one boot, my ambient light sensor (als) was on device1, so in_illuminance_raw was located in the /sys/bus/iio/devices/iio:device1/ folder. On the next boot the als was on device5. On another it was on device6. I found a solution while working with the developer for illuminanced. https://github.com/mikhail-m1/illuminanced/issues/24 Apparently, you can account for the change by using an asterisk instead of a number. So, instead of having your ambientLightFix_intel file cat /sys/bus/iio/devices/iio:device0/in_illuminance_raw on line 22, you should have it cat /sys/bus/iio/devices/iio:device*/in_illuminance_raw. I'll temoparily disable illuminanced, make this change to your script, then test it to see if it works.
That sounds like a reasonable solution
Ok, I made the change I listed to line 22 of the ambientLightFix_intel file and ran it as sudo. I'm getting the following errors: ./ambientLightFix_intel: line 43: 0: command not found ./ambientLightFix_intel: line 44: 0: command not found Steg: sensorGreater ./ambientLightFix_intel: line 43: 0: command not found ./ambientLightFix_intel: line 44: 0: command not found I don't know what's going on with that..
Did you replace the 1 with * in both the setup script and the Intel script?
sensorGreater is using /sys/class/backlight/intel_backlight/max_broghtness and /sys/class/backlight/intel_backlight/brightness and /sys/bus/iio/devices/iio:device*/in_illumonance_raw Can you check that you can access them?
I have the same issue as the hyukang2019. Script tells me, that my laptop (lenovo yoga 710-14ikb) has no ambient light sensors, but it has. Works perfectly in manjaro with gnome and win10 but not in the kde(
That is super interesting, the script works with GNOME but not with KDE. Is it on the same install?
I get "No sensors here... AmbientLightFix won't be able to run on your machine :-( " this error when I ran AmbientLightFix_RunME.sh eventhough I believe my laptop (xps 13 9310 2 in 1) has ambientlight sensor. it does show the light changes when i run monitor-sensor. Am i missing something? Thanks in advance
In case you actually have sensors my guess is that the system is calling them something else which leads to the script not finding them... I'll take a look at this later today. In the meantime, feel free to look at the commands in the script and see what you do have in the path where the light sensors should be :-) That can help me sort out what's wrong
I checked sys/bus/iio/devices/iio:device0, initially, it had in_illuminance_raw but then it changed it's name to "in_angl2_raw". why is it keep changing it's name? Is that normal?
What distro are you running?
garuda.
I have not used this together with Garuda, I developed on with Antergos... Both Arch-derivatives, so it shouldn't be that much difference on the level where this script operates... *scratches head* Would it be too much work for you to try out a different distro to see if something with garuda is the problem?
It's alright I can live without auto brightness but there are tons of configs in my current sys that I can't sacrifice. FYI, I did try auto brightness that comes as default in garuda gnome and it worked just fine out of the box so it's obvious that it's not my hardware problem. Thanks anyway for trying to help.
so when I tried sudo watch cat /sys/bus/iio/devices/iio:device0/in_illuminance_raw, it showed brightness changing in number but after enabling the the ambientLightFix_intel.service and rebooted the system, it just says "no such file or directory" obviously bc it changed it's name to something else by itself. Any tips?
It really should not change names...
This is really a GREAT little bash script, - unfortunately it is not compliant with an Apple iMac12,2 computer. The ALS sensor is present and active, it gives me currently a value of "1046": test@iMac-tmp:~$ cat /sys/bus/iio/devices/iio:device0/in_illuminance_raw 1046 But the "intel_backlight" is not present in that form, instead of it I have two others, "acpi_video0" and "radeon_bl0": test@iMac-tmp:~$ ls /sys/class/backlight/ acpi_video0 radeon_bl0 So, because the main GPU aka "DRI_PRIME=0" is the Radeon one (and not the Intel iGPU) I suppose the "radeon_bl0" is the right one. Maybe the script can be modified accordingly? Or alternatively I just need a way to disable the entire ALS feature permanently. This worked all fine under Kubuntu 20.04 LTS but not under 22.04 LTS. I was able to adjust the screen brightens previously manually via the corresponding Apple keyboard buttons. For whatever reason this doesn't works any longer under 22.04 most likely because the ALS sensor is now used as main and only source. When I tried it aggressively via the brightens buttons on the keyboard then KDE is crashing to the log-in screen.
Sounds strange that it worked on 20.04 but not 22.04... Does it crash to the login screen when Ambient Light Fix is not running as well? I'll try to look over the script tonight. I never had any AMD hardware to play with when I made it, so with your input it'll hopefully make the script better :-)
Thanks for the super fast answer. Just to understand me correctly, I mean the Ambient Light matter worked under 20.04 LTS without any script. Under 22.04 the backlight was always at the lowest level and no matter what have tried, I was not able to increase the backlight. Whatever, I have finally found a workaround at the ArchLinux "Backlight" site, - the kernel command-line option "acpi_backlight=vendor" did the trick! Everything works now again as in 20.04. This is true even for the "brightness buttons" on the Apple keyboard. So regarding this script, it will most likely also not work under Kubuntu 20.04 because it is not adjusted for the iMac 12,2 line computer. ;-)
Ah I see. I actually haven't used this script myself since I switched distros to Ubuntu and Fedora where ambient backlight works out of the box, haha :-D But I have updated ALF with the info you gave in your first comment, so it should work with radeon now... I hope, haha, can't check it myself XD
10 It just works as expected.
Nice that my script still can bring some happiness :-)