Is it possible to tweak settings if and only if the computer starts on battery power?
Why?
I usually work without battery, but when I use a battery I want it to last as long as possible. For that purpose I use little tweaks (granola for minimal power consumption, switching off wifi and bluetooth, and brightness settings).
What?
Whenever I boot my laptop on battery I have to manually tweak all these settings. In the beginning that was OK, but now I want these tweaks to be done automatically. What I want to be tweaked automatically when booting on battery power is
setting the laptop in flight mode (no wifi nor bluetooth)
dimming the screen to 50%
disabling all usb inputs (I often leave a few things in usb slots, but I do not want them activated)
set the power mode in granola to minimal consumption (this needs
sudo
).
Any ideas? A script that runs automatically when logging in on battery? Anything?