Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ let settings, client, device;

// Checks for changes in settings, must be disconnected in disable
let batteryPercentageWatcher;
let ACDefaultWatcher, batteryDefaultWatcher, platformProfileWatcher;
let ACDefaultWatcher, batteryDefaultWatcher, lockedDefaultWatcher;

let batteryThreshold, ACDefault, batteryDefault, activeProfile, perfDebounceTimerId;
let batteryThreshold, ACDefault, batteryDefault, lockedDefault, activeProfile, perfDebounceTimerId;

let powerManagerProxy, powerManagerCancellable, batteryThresholdWatcher;
let powerProfilesProxy, powerProfilesCancellable, powerProfileWatcher;
Expand Down Expand Up @@ -101,6 +101,7 @@ const getDefaults = () => {
ACDefault = settings.get_string("ac");
batteryDefault = settings.get_string("bat");
batteryThreshold = settings.get_int("threshold");
lockedDefault = settings.get_string("locked");
}

export default class PowerProfileSwitcher extends Extension {
Expand Down Expand Up @@ -131,6 +132,11 @@ export default class PowerProfileSwitcher extends Extension {
checkProfile
);

lockedDefaultWatcher = settings.connect(
"changed::locked",
checkProfile
);

powerManagerCancellable = new Gio.Cancellable();
powerManagerProxy = new PowerManagerProxy(Gio.DBus.system, UPOWER_BUS_NAME, UPOWER_OBJECT_PATH,
(proxy, error) => {
Expand Down Expand Up @@ -192,6 +198,7 @@ export default class PowerProfileSwitcher extends Extension {
settings.disconnect(batteryPercentageWatcher);
settings.disconnect(ACDefaultWatcher);
settings.disconnect(batteryDefaultWatcher);
settings.disconnect(lockedDefaultWatcher);

powerManagerProxy.disconnect(batteryThresholdWatcher);
powerManagerCancellable.cancel();
Expand All @@ -210,6 +217,6 @@ export default class PowerProfileSwitcher extends Extension {
powerManagerCancellable = null;
powerProfilesCancellable = null;
activeProfile = null;
switchProfile("balanced");
switchProfile(lockedDefault);
}
}
22 changes: 13 additions & 9 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"uuid": "power-profile-switcher@eliapasquali.github.io",
"name": "Power Profile Switcher",
"description": "Automatically switch between power profiles based on power supply and percentage.",
"version": 12,
"shell-version": ["45", "46"],
"url": "https://github.com/eliapasquali/power-profile-switcher",
"gettext-domain": "org.gnome.shell.extensions.power-profile-switcher",
"settings-schema": "org.gnome.shell.extensions.power-profile-switcher"
}
"_generated": "Generated by SweetTooth, do not edit",
"description": "Automatically switch between power profiles based on power supply and percentage.",
"gettext-domain": "org.gnome.shell.extensions.power-profile-switcher",
"name": "Power Profile Switcher",
"settings-schema": "org.gnome.shell.extensions.power-profile-switcher",
"shell-version": [
"45",
"46"
],
"url": "https://github.com/eliapasquali/power-profile-switcher",
"uuid": "power-profile-switcher@eliapasquali.github.io",
"version": 20
}
2 changes: 2 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var General = GObject.registerClass({
'ac_profile',
'bat_profile',
'threshold',
'locked_profile',
],
}, class General extends Adw.PreferencesPage {
_init(settings, params = {}) {
Expand All @@ -47,6 +48,7 @@ var General = GObject.registerClass({
'value',
Gio.SettingsBindFlags.DEFAULT
);
bindAdwComboRow(this._locked_profile, settings, 'locked', PROFILE_CHOICES);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<summary>On battery profile</summary>
<description>Select the default profile to use when running on battery</description>
</key>
<key name="locked" type="s">
<default>"balanced"</default>
<summary>Locked screen profile</summary>
<description>Select the default profile to use when screen is locked</description>
</key>
<key name="threshold" type="i">
<default>25</default>
<summary>Power saving threshold</summary>
Expand Down
9 changes: 8 additions & 1 deletion ui/general.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
<property name="model">platform_profile_model</property>
</object>
</child>

<child>
<object class="AdwComboRow" id="locked_profile">
<property name="title" translatable="yes">Locked screen profile</property>
<property name="subtitle" translatable="yes">Select the default profile to use when screen is locked</property>
<property name="model">platform_profile_model</property>
</object>
</child>
</object>
</child>

Expand Down Expand Up @@ -54,7 +62,6 @@
</items>
</object>


<object class="GtkAdjustment" id="threshold_adjustment">
<property name="page-increment">5.0</property>
<property name="step-increment">1.0</property>
Expand Down