2

I wrote myself a bash script and when this script is called it changes my display brightness. Now i want to run this script when my ac-adapter is unplugged or the ac-adapter gets plugged in. Where can I add some events?

1 Answers1

1

i want to run this script when my ac-adapter is unplugged or the ac-adapter gets plugged in

There's a couple of ways. I've written a script specifically for that purpose , which uses on_ac_power script that comes with Ubuntu by default. This method simply uses infinite while loop to constantly poll the return of on_ac_power. Starting this script is done using Startup Applications app which launches commands when user logs into Gnome or Unity.

Another approach is via ACPI events. As shown on Arch Wiki , you can place a script into /etc/acpi folder that will perform checks for the presence of a specific AC adapter in /sys/class/backlight folder, and change a specific value in a file accordingly.