I want to run this script on ubuntu 19.04, after booting the OS to restore the previous screen brightness:
echo 50 > /sys/class/backlight/nvidia_0/brightness
How can I run this script so it takes effect at the right moment?
I want to run this script on ubuntu 19.04, after booting the OS to restore the previous screen brightness:
echo 50 > /sys/class/backlight/nvidia_0/brightness
How can I run this script so it takes effect at the right moment?
In Ubuntu 20.04.2 LTS I solved this problem by creating a cron job:
and including this line at the end of the file:
I found that 2 seconds was enough time to override Nvidia's reset timing at boot. You can adjust the brightness level (80) to your own preference.
PS: Just found out that an additional fix is needed: even though the code above fixes brightness at boot, it won't do it when the computer wakes up from sleep/hibernation, Nvidia resets brightness to max again. To fix this, create in addition the following script in a file in the /lib/systemd/system-sleep/ folder:
Put it in a script eg brightness.sh. , with #!/bin/bash at the top (not sure if this is necessary) make it executable (right click, permissions, executable) , then put that in startup applications - Power Key then type startup, select Startup applications, add button, type (<> are your particular locations)
Your system may be setup to automatically restore the last brightness setting already. You can however edit
/etc/rc.local
and insert this line beforeexit 0
at the bottom:Note you can also use
cron@reboot
ifrc.local-service
isn't setup insystemd
: