Since power modes were introduced in Gnome, there is now the option to change between Power Saver, Balanced, and Performance mode manually in the drop down menu. This is a welcome integration in Gnome! However, I’ve had a number of times where I’ve undocked my laptop for a meeting and set it to Power Saver, came back, docked it, and wondered why my compiles were taking so long only to then remember I hadn’t switched back to Performance mode.
Is there any way to set it to automatically default to Power Saver mode when switching to battery power and default back to Performance when docked or on A/C power?
I understand that a GUI solution isn’t available, but I’m wondering if there may be a way in the meantime to set this based on an ACPI event for power source change triggering powerprofilesctl?
It looks like upowerd is detecting the change when I dock. I assume there’s probably some way to hook powerprofilesctl based on that detection from upowerd.
You may want to investigate ‘tlp’ anyway; it can also manage charging thresholds to improve the lifetime of your battery, and with the ‘tlp-rdw’ package it can manage switching between wired and wireless networks smoothly.
It looks like upowerd can be read from dbus and power-profiles-daemon ships with a dbus integration: /etc/dbus-1/system.d/net.hadess.PowerProfiles.conf
I’m just not sure how to connect the two events so that when upowerd detects a change, it can trigger a power profile change via dbus.
I’d really like to find a way using the native Gnome tools since I still want to be able to simply override it on demand. I’ve used other profiling methods in the past. I really want to find a way to make this one work better for me.
I could write a script to continuously poll this and wrap it in systemd, but I’d much rather there be a way to trigger it via dbus on a change in state of that value and that’s the part I’m currently missing.
I’m not sure if this is the proper way to do this, but it looks like I could write a systemd service to parse a readline out of this to trigger the power profile switch event:
Glad to hear you found a solution, but if you’re looking for a more “visible” one, I’d recommend looking on https://extensions.gnome.org/ There are a number of extensions that monitor and display status and events from the power system, and I have to believe at least one of them would have a “react to these transitions” type of feature.