Merge pull request #12 from Eeems/patch-1

Gnome 43 support
This commit is contained in:
Martin Zurowietz 2023-02-02 10:52:10 +01:00 committed by GitHub
commit 63103c7da6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 13 deletions

View file

@ -4,15 +4,16 @@ const Panel = imports.ui.main.panel;
class BaTimeExtension {
constructor() {
this.aggregateMenu = Panel.statusArea['aggregateMenu'];
this.originalIndicator = this.aggregateMenu._power;
this.customIndicator = new BaTime.imports.power.Indicator();
this.aggregateMenu = Panel.statusArea.quickSettings;
this.originalIndicator = this.aggregateMenu._system;
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

View file

@ -1,9 +1,7 @@
{
"shell-version": [
"40",
"41",
"42"
"43"
],
"uuid": "batime@martin.zurowietz.de",
"url": "https://github.com/mzur/gnome-shell-batime",

View file

@ -1,20 +1,22 @@
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;
let state = proxy.State;
if (this._proxy.State === UPower.DeviceState.FULLY_CHARGED) {
if (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 (state === UPower.DeviceState.CHARGING) {
seconds = proxy.TimeToFull;
} else if (state === UPower.DeviceState.DISCHARGING) {
seconds = proxy.TimeToEmpty;
} else if (state === UPower.DeviceState.PENDING_CHARGE) {
return '';
} else {
// state is PENDING_DISCHARGE or UNKNOWN