2

Whenever I boot, the brightness is set to full. I read this and make changes so that it do not reset every time I boot into my laptop.

But before this, I tried to change brightness before login, but brightness buttons only work when I log in. So after my problem of Brightness is reset to Maximum on every Restart is solved, I just want to know any way to change the brightness just after OS start, that is before login.

  • 1
    Take a look at this question: askubuntu.com/q/829814/295286 In particular , step 3 of my answer is the most relevant. While slightly different in context, it does ask setting the login screen brightness. Let me know if everything is clear there. If so desired, I can post alternative answer. – Sergiy Kolodyazhnyy Feb 28 '17 at 7:08
  • This /etc/lightdm/lightdm.conf file is empty. Is it strange or normal? – Siraj Alam Feb 28 '17 at 7:12
  • Normal. If it was not edites before, it will be.empty – Sergiy Kolodyazhnyy Feb 28 '17 at 7:22
  • May your question be closed as a duplicate then ? – Sergiy Kolodyazhnyy Feb 28 '17 at 7:31
  • yeah maybe you are right, but what I think, it would be better if someone come to this question after google it, so he got a direct solution here rather than going to step 3 of this. It would be difficult for anyone this. – Siraj Alam Feb 28 '17 at 7:34
2

Running a script before or once login screen appears

There are two ways to approach this:

  1. Place command or call to script in /etc/rc.local. For instance

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    # path to my script. Note the & at the end, it's important
    /home/serg/bin/brightness_set.sh &
    exit 0
    
  2. The login screen is actually known as desktop manager, and Ubuntu in particular uses lightdm desktop manager. Its configuration file /etc/lightdm/lightdm.conf can take greeter-setup-script= parameter to execute something before login screen actually shows up. For instance, you could do:

    [Seat:*]
    greeter-setup-script=/opt/set_brightness.py
    

    NOTE: Older versions of the header [SeatDefaults] is deprecated now, use [Seat:*]. Also, if you have never edited /etc/lightdm/lightdm.conf it will be blank - that's the normal behavior since 14.04 Ubuntu version.

Controlling the brightness:

Setting brightness will have to be done by writing to brightness file in /sys/class/backlight/<NAME> directory. There are couple different <NAME> versions than can appear, for example mine is /sys/class/backlight/intel_backlight , so you will need to figure out the name your own computer uses or alternatively use /sys/class/backlight/*/brightness. There is also max_brightness file in the same location, which you can use as 100% value to calculate brightness to set. Both files accept integer value.

Common way to write into that file is via echo 123 | sudo tee /sys/class/backlight/*/brightness from command line. If you are running a script via /etc/rc.local or via greeter-setup-script= parameter mentioned above, sudo is not necessary, as both method run scripts with root privillege ( which is also important to remember for security reasons, so ensure your script is accessible only to your user or root only ) .

There are also alternatives to writing into /sys , but not all of them are good. In my experience xbacklight doesn't work for Ubuntu users and xrandr --output SCREEN_NAME --brightness INT is only a software solution (i.e., it doesn't actually decrease power of the screen, only makes screen turn darker color).

Additional resources

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.