🎉 Add option to disable effects if on battery power
This commit is contained in:
@@ -73,6 +73,12 @@ class Extension {
|
||||
// We will use extensionThis to refer to the extension inside the patched methods.
|
||||
const extensionThis = this;
|
||||
|
||||
// This is used to get the battery state.
|
||||
const UPowerProxy = Gio.DBusProxy.makeProxyWrapper(
|
||||
utils.getStringResource('/interfaces/org.freedesktop.UPower.xml'));
|
||||
this._upowerProxy = new UPowerProxy(Gio.DBus.system, 'org.freedesktop.UPower',
|
||||
'/org/freedesktop/UPower');
|
||||
|
||||
// We will monkey-patch these methods. Let's store the original ones.
|
||||
this._origAddWindowClone = Workspace.prototype._addWindowClone;
|
||||
this._origWindowRemoved = Workspace.prototype._windowRemoved;
|
||||
@@ -365,6 +371,13 @@ class Extension {
|
||||
return;
|
||||
}
|
||||
|
||||
// We may have to do nothing if running on battery power.
|
||||
if (this._settings.get_boolean('disable-on-battery') && this._upowerProxy.OnBattery &&
|
||||
previewNick == '') {
|
||||
this._fixAnimationTimes(isDialogWindow, forOpening, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// There is the weird case where an animation is already ongoing. This happens when a
|
||||
// window is closed which has been created before the session was started (e.g. when
|
||||
// GNOME Shell has been restarted in the meantime).
|
||||
|
||||
Reference in New Issue
Block a user