Skip to content
Merged
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
31 changes: 29 additions & 2 deletions files/usr/share/cinnamon/applets/power@cinnamon.org/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
this._proxy.connect("g-properties-changed", Lang.bind(this, this._devicesChanged));
global.settings.connect('changed::device-aliases', Lang.bind(this, this._on_device_aliases_changed));
this.settings.bind("labelinfo", "labelinfo", this._devicesChanged);
this.settings.bind("showmulti", "showmulti", this._devicesChanged);

this._devicesChanged();
}));
Expand Down Expand Up @@ -580,7 +581,7 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
// The menu is built. Below, we update the information present in the panel (icon, tooltip and label)
this.set_applet_enabled(true);
let panel_device = null;
if (this._primaryDevice != null) {
if (this._primaryDevice != null && (!this.showmulti || this._devices.length === 1)) {
this.showDeviceInPanel(this._primaryDevice);
}
else {
Expand All @@ -589,8 +590,34 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
}
else if (this._devices.length > 1) {
// Show a summary
let labelText = "";
if (this.labelinfo !== "nothing") {
for (let i = 0; i < this._devices.length; i++) {
labelText += i + ': ';
let [, , , , , percentage, , , seconds] = this._devices[i];
if (this.labelinfo == "time" && seconds !== 0) {
let time = Math.round(seconds / 60);
let minutes = time % 60;
let hours = Math.floor(time / 60);
labelText += C_("time of battery remaining", "%d:%02d").format(hours, minutes);
}
else if (this.labelinfo == "percentage" || (this.labelinfo == "percentage_time" && seconds === 0)) {
labelText += C_("percent of battery remaining", "%d%%").format(Math.round(percentage));
}
else if (this.labelinfo == "percentage_time") {
let time = Math.round(seconds / 60);
let minutes = Math.floor(time % 60);
let hours = Math.floor(time / 60);
labelText += C_("percent of battery remaining", "%d%%").format(Math.round(percentage)) + " (" +
C_("time of battery remaining", "%d:%02d").format(hours,minutes) + ")";
}
if (i !== this._devices.length - 1) {
labelText += ' ';
}
}
}
this.set_applet_tooltip(devices_stats.join(", "));
this.set_applet_label("");
this.set_applet_label(labelText);
let icon = this._proxy.Icon;
if(icon) {
if (icon != this.panel_icon_name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@
"Show percentage and time remaining": "percentage_time",
"Hide label": "nothing"
}
},
"showmulti" : {
"type" : "switch",
"default" : false,
"description": "Always show all batteries",
"tooltip": "Check this to always show multiple batteries in the panel, regardless of whether one of them is marked primary."
}
}