How to make my screen brightness not change when I plug my laptop in

52,893

I tested a solution that works fine for me. One solution is to add a script file in /etc/pm/power.d/

Just creates a file

sudo vi /etc/pm/power.d/run_after_pwrmanagmt.sh

Then writes this code into this file :

case "${1}" in
    true) #battery_mode
        xinput set-int-prop 12 277 8 2 3 0 0 1 3 2
        echo 4000 > /sys/class/backlight/intel_backlight/brightness
;;
    false) #ac_mode
        xinput set-int-prop 12 277 8 2 3 0 0 1 3 2
        echo 4000 > /sys/class/backlight/intel_backlight/brightness
esac

Now, you need to give execution rights to this file by typing

sudo chmod +x /etc/pm/power.d/run_after_pwrmanagmt.sh

Now it should work fine, just test to plug/unplug your computer. Note that you can do similar things after a suspend (/etc/pm/sleep.d/run_after_sleep.sh), that's how I found out this solution... You will find information on the web...

Note that xinput is just a command for my trackpad to set the middle button working... You should skip the two lines xinput if not needed (or adapt ). For the value 4000, it may be diffrent for each screen, you should first see what is your max value with the command cat /sys/class/backlight/intel_backlight/max_brightness

Hope this helps, and that the moderator will not delete this post since this is an answer and not a question. Thanks

Share:
52,893

Related videos on Youtube

DavidW
Author by

DavidW

Updated on September 18, 2022

Comments

  • DavidW
    DavidW over 1 year

    I do not want my laptop to change brightness when my laptop power is plugged in or unplugged. I set my brightness based on how bright my surroundings are. If I am in a dark room, I set my brightness very low and when I plug my laptop in the brightness gets set to maximum which feels like sticking my eyes in boiling lava.

    In System Settings â–¸ Brightness and Lock the Dim screen to save power checkbox is unchecked.

    My laptop is an HP Mini 110

    In case it is an acpi issue I have put my acpi-support file here
    [link removed because it expired]

    • Admin
      Admin almost 12 years
      Are you still using ACPI events?
    • Admin
      Admin almost 12 years
      How can I check?
    • Admin
      Admin over 7 years
      I have Dell v131 laptop. This issue finally disappeared after upgrade to ubuntu 16.10.
  • DavidW
    DavidW almost 12 years
    The checkbox "Dim screen to save power" is not checked.
  • thomasrutter
    thomasrutter almost 12 years
    In that case you may want to add this information to your question, as well as information about which laptop you have.
  • intrepidis
    intrepidis almost 10 years
    This is a super-complicated answer for such a simple question! Try looking at the other answers for a something simpler.
  • Pithikos
    Pithikos over 9 years
    What if there is no directory power.d?
  • LogicStuff
    LogicStuff almost 8 years
    @Albin For me, the script couldn't be run but manually (yes, I marked it as executable).
  • Andrea Lazzarotto
    Andrea Lazzarotto over 7 years
    You should consider editing out the xinput thing. I see people everywhere copy-pasting your solution with the xinput command that they do not need at all.