I was thinking that it would be nice to have a bash script that automatically detect when the power adapter is disconnected and switch to a lighweight compositor to provide the best possible battery life, and vice versa, when the adapter is plugged in switch again to compiz/compton.
I am kinda new to linux so i have no clue how to realize it
Anyone think is it a good idea? (and wanna help realize it?)
As far as my opinion goes, doing it manually would be better.
And switching so frequently in pace with whether the adapter is plugged or unplugged seems kinda harsh and unusual for your system.
Just find the right compositor that works with your hardware and stick to it.
Again, this is only my opinion.
Navigate to /sys/class/power_supply first, to make sure that the ‘ac’ and ‘battery’ folders exist and check their names. In my case ‘ac’ was all capitals (‘AC’).
Compton is pretty light. Especially if it has minimal effects applied. Perhaps, a better option would not be to change compositor. But, to switch off compton, swap out the compton conf file for a less heavy one, then switch compton back on. And, of course, vice versa.
The above could all, conceivably, be done in a bash script. The only bit I don’t know (which is the bit you need) is how to have the system detect if it is plugged into the mains.