2

I am working on a XMG Core 15 with Ubuntu 20.04. (kernel 5.11.0.27-generic since the newer ones cause problems with my screens) and a NVIDIA GeForce RTX 2060 (NVIDIA driver 470) and AMD Ryzen 7 4800H. My problem is that every time I reboot my laptop, the display brightness resets to the minimum but the actual screen brightness is maximum. If I double check in settings the slider on brightness is in the minimum position. The strange thing is if I plug in or out the power cable the screen brightness jumps to the value in the settings. It is no big problem but it is really annoying. My question is now, how can I prevent it from resetting the brightness every reboot and set the brightness to a specific value. I hope I have described the problem in an comprehensible way.

If you need additional information feel free to ask. I am glad for every help of you.

Thanks and best regards, Daniel

Update #1. After undo the first step and do the steps from Update #1 the brightness still resets after rebooting. I did the following modifications:

  • Create a file -rwxr-xr-x 1 root root 180 Feb 7 19:20 set_brightness.sh* in /etc/rc.local with the following content:

    #!/bin/sh
    #. Set specific brightness level to work around bug
    #. See /etc/systemd/system/set_brightness.service
    #.
    sleep 15; echo 255 | tee /sys/class/backlight/amdgpu_bl0/brightness

  • Create second file -rw-r--r-- 1 root root 172 Feb 7 19:23 set_brightness.service in /etc/systemd/system with the following content:

    [Unit]

    Description=Set screen brightness to work around bug

    [Service]

    Type=oneshot

    ExecStart=/bin/sh /etc/rc.local/set_brightness.sh

    [Install]

    WantedBy=multi-user.target

The status looks as follow:

(base) daniel@xmg-daniel:/etc/systemd/system$ systemctl status set_brightness.service
● set_brightness.service - Set screen brightness to work around bug
     Loaded: loaded (/etc/systemd/system/set_brightness.service; disabled; vendor preset: enabled)
     Active: inactive (dead)

Output of ls -al /sys/class/backlight/ :

total 0
drwxr-xr-x  2 root root 0 Feb  7 19:49 .
drwxr-xr-x 84 root root 0 Feb  7 19:49 ..
lrwxrwxrwx  1 root root 0 Feb  7 19:49 amdgpu_bl0 -> ../../devices/pci0000:00/0000:00:08.1/0000:06:00.0/backlight/amdgpu_bl0

Some other remarks: With the first modifications the slider of the brightness was set to the same position as before rebooting also the actual brightness was the same as before rebooting, but after pluging in or out the power cable the brightness was set automatically to minimum. Also with this modification my bluetooth turned on automatically after rebooting although I turned it off everytime. Undoing the first modifications and doing update #1 the bluetooth issue was solved but it looks like the workaround is not working correctly.

After doing the steps from @heynnema mentioned in the comments I have the following output for systemctl status set_brightness.service:

● set_brightness.service - Set screen brightness to work around bug
     Loaded: loaded (/etc/systemd/system/set_brightness.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Mon 2022-02-07 20:14:00 CET; 7s ago
    Process: 4546 ExecStart=/bin/sh /etc/rc.local/set_brightness.sh (code=exited, status=0/SUCCESS)
   Main PID: 4546 (code=exited, status=0/SUCCESS)

Feb 07 20:13:45 xmg-daniel systemd[1]: Starting Set screen brightness to work around bug...
Feb 07 20:14:00 xmg-daniel sh[4549]: 255
Feb 07 20:14:00 xmg-daniel systemd[1]: set_brightness.service: Succeeded.
Feb 07 20:14:00 xmg-daniel systemd[1]: Finished Set screen brightness to work around bug.

But the problem is still there. When plugging in or out the power cable the brightness switches automatically to minimum.

Sorry for the bad formatting of my update, I wanted to code sample the content of the two files but somehow it is not working ...

1
  • May be overkill but you can use eyesome to automatically set your brightness and color temperature when resuming from suspend. Disclaimer: I wrote the app. Feb 5, 2022 at 4:23

1 Answer 1

4

What happens is at boot time (and shutdown time), /lib/systemd/system/[email protected] tries to restore (save) the backlight levels, and it doesn't always perform this action correctly. Hence the lowered screen brightness after a boot. cat the file if you wish to see its contents. Type man systemd-backlight to get more background information.

Edit /etc/default/grub...

sudo -H gedit /etc/default/grub

Find the line that looks like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Edit it to look like this:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash systemd.restore_state=0"

Then:

sudo update-grub

reboot

Update #1:

This may work better than the kernel line mod from above. It'll take a little playing to get it going in your config, but I think you've got the skills required :-)

  • first, undo the mods from above

  • see if a file called /etc/rc.local exists on your computer

    • ls -al /etc/rc.local
  • if it doesn't exist, create a folder at /etc/rc.local

    • sudo mkdir /etc/rc.local
  • if it does exist, talk to me before proceeding

  • drop this into the /etc/rc.local folder, and name it set_brightness.sh


#!/bin/sh
# Set specific brightness level to work around bug
# See /etc/systemd/system/set_brightness.service
#
sleep 15; echo 80 | tee /sys/class/backlight/dell_uart_backlight/brightness

Note: You'll need to change the dell_uart_backlight in the pathname for your own configuration

Note: If you have a slow system, you may need to increase the sleep timer

Note: 80 is the desired brightness setting

It should look like this:

-rwxr-xr-x   1 root root   189 Jan 17 15:57 set_brightness.sh
  • drop this into the /etc/systemd/system/ folder, and name it set_brightness.service

[Unit]
Description=Set screen brightness to work around bug

[Service]
Type=oneshot
ExecStart=/bin/sh /etc/rc.local/set_brightness.sh

[Install]
WantedBy=multi-user.target

It should look like this:

-rw-r--r-- 1 root root 172 Sep 27 16:24 /etc/systemd/system/set_brightness.service
  • sudo systemctl enable set_brightness.service

  • then reboot

And this status:

$ systemctl status set_brightness.service

○ set_brightness.service - Set screen brightness to work around bug
     Loaded: loaded (/etc/systemd/system/set_brightness.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Thu 2022-02-03 20:13:23 PST; 1 day 10h ago
    Process: 1102 ExecStart=/bin/sh /etc/rc.local/set_brightness.sh (code=exited, status=0/SUCCESS)
   Main PID: 1102 (code=exited, status=0/SUCCESS)
        CPU: 23ms

Feb 03 20:13:08 al-Inspiron-7700-AIO systemd[1]: Starting Set screen brightness to work around bug...
Feb 03 20:13:23 al-Inspiron-7700-AIO sh[3320]: 80
Feb 03 20:13:23 al-Inspiron-7700-AIO systemd[1]: set_brightness.service: Deactivated successfully.
Feb 03 20:13:23 al-Inspiron-7700-AIO systemd[1]: Finished Set screen brightness to work around bug.

Update #2:

Both mods didn't solve the problem. Both mods removed.

However, booting to a Ubuntu Live 21.10 solves the problem, but the user cannot upgrade at this time due to some other software issues.

14
  • Thank you @heynnema! It almost solved my problem. The slider in settings is set to max after rebooting but if I plug in or out the power cable it still switches back to minimum. Do you also know how to solve this problem?
    – CFDaniel
    Feb 5, 2022 at 8:07
  • @CFDaniel See Update #1 in my answer. Maybe it'll work better.
    – heynnema
    Feb 5, 2022 at 15:09
  • @CFDaniel Status please...
    – heynnema
    Feb 6, 2022 at 3:14
  • Hello @heynnema and sorry for late reply. There is no file/folder called rc.local, there are only folders like rc0.d, rc1.d and so on. Can I then continue with the next steps as you described?
    – CFDaniel
    Feb 7, 2022 at 16:30
  • @CFDaniel Yes. Carry on. Did you undo the first mod? Report back.
    – heynnema
    Feb 7, 2022 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .