2

I would like to have a bash script to be executed when I switch to battery alimentation, is this possible?

1 Answers1

1

yes there is a way.

From the Advanced Power Management (APM) daemon (apmd) man-page . This is a program. so when you remove the battery automatically this program will run. so you can use a condition to check the status of this program. If condition done then you can run the script else you can wait until it will runs.

change power
              Invoked when the APM subsystem reports a change in power status,
              such as a switch from mains to battery power.
Raja G
  • 102,391
  • 106
  • 255
  • 328