From 610e47e8864a3e970f9dbe856343bce4516cd771 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 20 Nov 2022 17:42:12 -0700 Subject: [PATCH 1/4] Gnome 43 support --- batime@martin.zurowietz.de/extension.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batime@martin.zurowietz.de/extension.js b/batime@martin.zurowietz.de/extension.js index 8a99e5c..053086b 100644 --- a/batime@martin.zurowietz.de/extension.js +++ b/batime@martin.zurowietz.de/extension.js @@ -4,8 +4,8 @@ const Panel = imports.ui.main.panel; class BaTimeExtension { constructor() { - this.aggregateMenu = Panel.statusArea['aggregateMenu']; - this.originalIndicator = this.aggregateMenu._power; + this.aggregateMenu = Panel.statusArea['quickSettings']; + this.originalIndicator = this.aggregateMenu._system; this.customIndicator = new BaTime.imports.power.Indicator(); this.aggregateMenu._indicators.replace_child( this.originalIndicator, From 4dd9ac58de41c5c2dd9f0c5c54f7531a4f54f56b Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 20 Nov 2022 18:33:38 -0700 Subject: [PATCH 2/4] Get working on Gnome 43 --- batime@martin.zurowietz.de/extension.js | 2 +- batime@martin.zurowietz.de/metadata.json | 4 +--- batime@martin.zurowietz.de/power.js | 15 ++++++++------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/batime@martin.zurowietz.de/extension.js b/batime@martin.zurowietz.de/extension.js index 053086b..6f92d8f 100644 --- a/batime@martin.zurowietz.de/extension.js +++ b/batime@martin.zurowietz.de/extension.js @@ -4,7 +4,7 @@ const Panel = imports.ui.main.panel; class BaTimeExtension { constructor() { - this.aggregateMenu = Panel.statusArea['quickSettings']; + this.aggregateMenu = Panel.statusArea.quickSettings; this.originalIndicator = this.aggregateMenu._system; this.customIndicator = new BaTime.imports.power.Indicator(); this.aggregateMenu._indicators.replace_child( diff --git a/batime@martin.zurowietz.de/metadata.json b/batime@martin.zurowietz.de/metadata.json index 1805cce..208d5b5 100644 --- a/batime@martin.zurowietz.de/metadata.json +++ b/batime@martin.zurowietz.de/metadata.json @@ -1,9 +1,7 @@ { "shell-version": [ - "40", - "41", - "42" + "43" ], "uuid": "batime@martin.zurowietz.de", "url": "https://github.com/mzur/gnome-shell-batime", diff --git a/batime@martin.zurowietz.de/power.js b/batime@martin.zurowietz.de/power.js index a16140a..d19d3df 100644 --- a/batime@martin.zurowietz.de/power.js +++ b/batime@martin.zurowietz.de/power.js @@ -1,20 +1,21 @@ const { GObject} = imports.gi; const UPower = imports.gi.UPowerGlib; -const BaseIndicator = imports.ui.status.power.Indicator; +const BaseIndicator = imports.ui.status.system.Indicator; var Indicator = GObject.registerClass( class Indicator extends BaseIndicator { // Adapted from _getStatus of the parent. _getTime() { let seconds = 0; + let proxy = this._systemItem.powerToggle._proxy; - if (this._proxy.State === UPower.DeviceState.FULLY_CHARGED) { + if (proxy.State === UPower.DeviceState.FULLY_CHARGED) { return ''; - } else if (this._proxy.State === UPower.DeviceState.CHARGING) { - seconds = this._proxy.TimeToFull; - } else if (this._proxy.State === UPower.DeviceState.DISCHARGING) { - seconds = this._proxy.TimeToEmpty; - } else if (this._proxy.State === UPower.DeviceState.PENDING_CHARGE) { + } else if (proxy.State === UPower.DeviceState.CHARGING) { + seconds = proxy.TimeToFull; + } else if (proxy.State === UPower.DeviceState.DISCHARGING) { + seconds = proxy.TimeToEmpty; + } else if (proxy.State === UPower.DeviceState.PENDING_CHARGE) { return ''; } else { // state is PENDING_DISCHARGE or UNKNOWN From af03075ef38beb26566d46485f4f891bfeca3623 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 20 Nov 2022 18:35:22 -0700 Subject: [PATCH 3/4] Small optimization --- batime@martin.zurowietz.de/power.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/batime@martin.zurowietz.de/power.js b/batime@martin.zurowietz.de/power.js index d19d3df..a544a5f 100644 --- a/batime@martin.zurowietz.de/power.js +++ b/batime@martin.zurowietz.de/power.js @@ -7,15 +7,15 @@ var Indicator = GObject.registerClass( // Adapted from _getStatus of the parent. _getTime() { let seconds = 0; - let proxy = this._systemItem.powerToggle._proxy; + let state = this._systemItem.powerToggle._proxy.State; - if (proxy.State === UPower.DeviceState.FULLY_CHARGED) { + if (state === UPower.DeviceState.FULLY_CHARGED) { return ''; - } else if (proxy.State === UPower.DeviceState.CHARGING) { + } else if (state === UPower.DeviceState.CHARGING) { seconds = proxy.TimeToFull; - } else if (proxy.State === UPower.DeviceState.DISCHARGING) { + } else if (state === UPower.DeviceState.DISCHARGING) { seconds = proxy.TimeToEmpty; - } else if (proxy.State === UPower.DeviceState.PENDING_CHARGE) { + } else if (state === UPower.DeviceState.PENDING_CHARGE) { return ''; } else { // state is PENDING_DISCHARGE or UNKNOWN From 11affed9bbffc1064949f84bbd3586e6be29668b Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 20 Nov 2022 18:42:13 -0700 Subject: [PATCH 4/4] Fix runtime issue and expose new indicator --- batime@martin.zurowietz.de/extension.js | 3 ++- batime@martin.zurowietz.de/power.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/batime@martin.zurowietz.de/extension.js b/batime@martin.zurowietz.de/extension.js index 6f92d8f..65f5b75 100644 --- a/batime@martin.zurowietz.de/extension.js +++ b/batime@martin.zurowietz.de/extension.js @@ -6,13 +6,14 @@ class BaTimeExtension { constructor() { this.aggregateMenu = Panel.statusArea.quickSettings; this.originalIndicator = this.aggregateMenu._system; - this.customIndicator = new BaTime.imports.power.Indicator(); + this.aggregateMenu._system = this.customIndicator = new BaTime.imports.power.Indicator(); this.aggregateMenu._indicators.replace_child( this.originalIndicator, this.customIndicator ); } destroy() { + this.aggregateMenu._system = this.originalIndicator; this.aggregateMenu._indicators.replace_child( this.customIndicator, this.originalIndicator diff --git a/batime@martin.zurowietz.de/power.js b/batime@martin.zurowietz.de/power.js index a544a5f..0e4093a 100644 --- a/batime@martin.zurowietz.de/power.js +++ b/batime@martin.zurowietz.de/power.js @@ -7,7 +7,8 @@ var Indicator = GObject.registerClass( // Adapted from _getStatus of the parent. _getTime() { let seconds = 0; - let state = this._systemItem.powerToggle._proxy.State; + let proxy = this._systemItem.powerToggle._proxy; + let state = proxy.State; if (state === UPower.DeviceState.FULLY_CHARGED) { return '';