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?
Asked
Active
Viewed 750 times
1 Answers
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.

Sergiy Kolodyazhnyy
- 105,154
- 20
- 279
- 497
/etc/pm/power.d
in 15.10, so I guess that wouldn't work. – kos Mar 03 '16 at 11:49