How to set laptop screen brightness on startup

I have an ASUS G55v laptop. After installing OpenSuSE 15.0, 15.1 and 15.2 with Gnome and Nvidia graphic drivers. The screen brightness isn’t restored at the next start-up. Once the login screen appears and after logging in the function keys work to set the brightness.

NOTE: The function keys worked for me upon installing Leap 15.2 and the latest Nvidia drivers. I don’t recall if I had to do something else to get the function keys working in prior versions. If I did, the answer to that can be found on the Internet.

I read several articles on the Internet about how to set a default brightness upon start-up but none of them were working for me. After several hours of troubleshooting, this is what worked for me. I’m not claiming it’s perfect but it works. As soon as the login screen appears the brightness is set to my default setting.

First, create a bash script /usr/bin/ There are other directories that you may be able to use, such as /usr/local/bin. The contents of the file look like this:

#! /bin/sh
# Sets the screen brightness.

sudo touch /sys/class/backlight/nvidia_0/brightness
sudo /bin/echo 15 > /sys/class/backlight/nvidia_0/brightness

You probably don’t need the touch command.

Then, create a systemd service /etc/systemd/system/set_brightness.service. You will see commented lines in the code below. I started with a service that several others suggested but discovered some issues. Keep reading after the code block.

Description=Sets the brightness. display-manager.service display-manager.service

ExecStart=/bin/bash /usr/bin/
#ExecStart=/bin/echo 15 > /sys/class/backlight/acpi_video0/brightness


The loaded the service too early. Upon booting, the directory /sys/class/backlight/nvidia_0/brightness doesn’t exist. /sys/class/backlight/acpi_video0/brightness exists so I knew the directory was accessible if it actually existed.

You probably don’t need the WorkingDirectory= line.

It was when I created these two lines that things began working.The target that made things begin working is I don’t know if any of the other targets or services are required. I had spent so many hours working on this that I stopped as soon as the brightness was successfully set. display-manager.service display-manager.service

Once you create the service file you have to run “sudo systemctl daemon-reload”.

You can test the service with “sudo systemctl start set_brightness”. If the test succeeds, restart the computer. If the service and script files work, the brightness will go down as soon as the login screen is displayed. You can still use the function keys to adjust the brightness.

There may be several other ways to accomplish the same thing. The important thing is that the line has to be removed from the [INSTALL] block and added to the [UNIT] block.