You are not logged in.

#1 2021-02-09 19:57:26

lazaro92
Member
Registered: 2021-01-04
Posts: 11

Restore previously saved brightness when turn on the system

Hi I have writted the next unit, with the help of the wiki:

File found in /etc/systemd/system/on-turn-on-system.service

[Unit]
Description="Services that start when the system is turned on"

[Service]
Type=oneshot
ExecStart="light -I"

[Install]
WantedBy=multi-user.target 

The idea is to change screen brightness from the last session with light -I, but when the system is starting it says:

Failed to start "Services that start when the system is turned on"

Also I have granted execution privilegies:

-rwxr-xr-x 1 root root 154 Feb  9 20:18 /etc/systemd/system/on-turn-on-system.service

What is wrong? What can I do?

Offline

#2 2021-02-09 21:35:24

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Restore previously saved brightness when turn on the system

lazaro92 wrote:

What is wrong? What can I do?

The ExecStart line should have the full path to an executable listed and it shouldn't have quotation marks. The unit file itself doesn't need to be executable. Check the systemd journal to find out why it's failing.

The backlight level should be restored automagically by systemd but there's a bug in the amdgpu driver that stops this from working.

I use this workaround:

# systemctl edit systemd-backlight@backlight:amdgpu_bl0.service

Then enter

[Service]
ExecStart=
ExecStart=/bin/cp /var/brightness /sys/class/backlight/amdgpu_bl0
ExecStop=
ExecStop=/bin/cp /sys/class/backlight/amdgpu_bl0/brightness /var

Change that to match the directory name under /sys/class/backlight/ in your system.

I also had to mask systemd-backlight@backlight:acpi_video0.service, YMMV.

There is an alternative solution in the ArchWiki but I prefer my hack :-)


Jin, Jîyan, Azadî

Offline

#3 2021-02-12 19:27:46

lazaro92
Member
Registered: 2021-01-04
Posts: 11

Re: Restore previously saved brightness when turn on the system

For the moment I have set a default number to always change the light when I turn on the laptop in a rule (/etc/udev/rules.d/81-backlight.rules):

# Set backlight level to 300
SUBSYSTEM=="backlight", ACTION=="add", KERNEL=="intel_backlight", ATTR{brightness}="300"

I have found that my system uses /sys/class/backlight/intel_backlight/ and I have checked the maximum value (4882) so I putted the 300 in the rule.

I ha found this solution in the wiki but I don't find the systemd-backlight@.service.

Last edited by lazaro92 (2021-02-12 19:47:18)

Offline

#4 2021-02-13 21:01:21

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Restore previously saved brightness when turn on the system

lazaro92 wrote:

I don't find the systemd-backlight@.service

$ pacman -F systemd-backlight@.service
core/systemd 247.3-1 [installed]
    usr/lib/systemd/system/systemd-backlight@.service
$

So check

pacman -Qk systemd

If the file really is missing then reinstall the systemd package.

If the unit file is present then check

systemctl status systemd-backlight.slice

And also interrogate the journal.


Jin, Jîyan, Azadî

Offline

Board footer

Powered by FluxBB