How to respect Battery Saving Mode?

I have some apps which to things like check for data updates online, or have systemd services packaged which to some background processing - some of which may be resource intensive or otherwise contradict the purposes of “battery saving mode”.

How can I detect (in a hopefully simple manner) that BSM is active, and that my services/apps shouldn’t do their thing?

I know about

mcetool -N | grep  'saving mode'
Power saving mode:                   enabled (inactive)
Forced power saving mode:            disabled
 busctl call  "com.nokia.mce" /com/nokia/mce/request "com.nokia.mce.request" get_psm_state

but are there other ways (e.g. query a dbus service, check for presence of a file, read a dconf key)?

2 Likes

Well, mce is the dbus service from which the info is available:

But there is also libmce-qt and QMcePowerSaveMode class that makes things a bit simpler

There is also runnable qml example here:

4 Likes

Lovely! Thanks a lot!