0

As you may know, screen brightness drains battery, that's why it is considered a big problem for laptops (at least for me).

I can change the screen brightness but every time ubuntu boots up I will have to change it again.

Luckily, you can write a script that does that for you. However, when the laptop is plugged in I do want the maximum brightness; which means I will have to do that by myself every time I plug in the laptop.

Is there a script that detect if the laptop is charging or not and sets the brightness level accordingly?

1

On my laptop I can check the contents of the file /sys/class/power_supply/C1BC/online: if the laptop is plugged in this file contains 1, otherwise it contains 0.

For example,

if [ "1" = "`cat /sys/class/power_supply/C1BC/online`" ]; then
  echo "Laptop is charging/plugged"
else
  echo "Laptop is discharging/unplugged"
fi

Note. As confirmed by the OP, the C1BC part is system dependent.

  • 1
    Thanks, it worked. Mine was ACAD though. – Mhmd Nov 13 '14 at 19:46
0

Try this

To adjust brightness in xubuntu or ubuntu Open a terminal window, and execute this command to edit /etc/rc.local:

sudo nano /etc/rc.local

Add this before the last line “exit 0″:

echo xx > /sys/class/backlight/acpi_video0/brightness

Where number xx is the value of your screen brightness of your choice.

The maximum value for brightness can be found with:

cat /sys/class/backlight/acpi_video0/max_brightness

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.