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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ Sensor data is obtained from the system using hwmon and GTop. Core Coding and th

| Description | Command |
| --- | --- |
| Launch preferences | `gnome-shell-extension-prefs Vitals@CoreCoding.com` |
| Launch preferences | `gnome-extensions prefs Vitals@CoreCoding.com` |
| View logs | ``journalctl --since="`date '+%Y-%m-%d %H:%M'`" -f \| grep Vitals`` |
| Compile schemas | `glib-compile-schemas --strict schemas/` |
| Compile translation file | `msgfmt vitals.po -o vitals.mo` |
| Launch Wayland virtual window | `dbus-run-session -- gnome-shell --nested --wayland` |
| Launch Wayland virtual window | `dbus-run-session -- gnome-shell --devkit --wayland` |
| Read hot-sensors value | `dconf read /org/gnome/shell/extensions/vitals/hot-sensors` |
| Write hot-sensors value | `dconf write /org/gnome/shell/extensions/vitals/hot-sensors "['_memory_usage_', '_system_load_1m_']"`<br/>This value configures the list of sensors that show up in the panel. To specify a sensor name, click on the extension to show the drop-down menu, then take the category label and the label of the individual sensor, convert them to `snake_case`, and format them like this: `_category_sensor_`.|

GNOME Shell 50 is supported. For older GNOME Shell versions that do not support `--devkit`, use `dbus-run-session -- gnome-shell --nested --wayland` when testing in a nested session.

## Donations
[Please consider donating if you find this extension useful.](https://corecoding.com/donate.php)

Expand Down
30 changes: 22 additions & 8 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ var VitalsMenuButton = GObject.registerClass({
this._initializeTimer();
}

_getActor(item) {
return item?.actor ?? item;
}

_closeMenu() {
if (this.menu?.close)
this.menu.close();
else if (this.menu?._getTopMenu)
this.menu._getTopMenu().close();
}

_initializeMenu() {
// display sensor categories
for (let sensor in this._sensorIcons) {
Expand Down Expand Up @@ -157,21 +168,21 @@ var VitalsMenuButton = GObject.registerClass({
// custom round monitor button
let monitorButton = this._createRoundButton('org.gnome.SystemMonitor-symbolic', _('System Monitor'));
monitorButton.connect('clicked', (self) => {
this.menu._getTopMenu().close();
this._closeMenu();
Util.spawn(this._settings.get_string('monitor-cmd').split(" "));
});
customButtonBox.add_child(monitorButton);

// custom round preferences button
let prefsButton = this._createRoundButton('preferences-system-symbolic', _('Preferences'));
prefsButton.connect('clicked', (self) => {
this.menu._getTopMenu().close();
this._closeMenu();
this._extensionObject.openPreferences();
});
customButtonBox.add_child(prefsButton);

// now add the buttons to the top bar
item.actor.add_child(customButtonBox);
this._getActor(item).add_child(customButtonBox);

// add buttons
this.menu.addMenuItem(item);
Expand Down Expand Up @@ -397,14 +408,15 @@ var VitalsMenuButton = GObject.registerClass({
_initializeMenuGroup(groupName, optionName, menuSuffix = '', position = -1) {
this._groups[groupName] = new PopupMenu.PopupSubMenuMenuItem(_(this._ucFirst(groupName) + menuSuffix), true);
this._groups[groupName].icon.gicon = Gio.icon_new_for_string(this._sensorIconPath(groupName));
const groupActor = this._getActor(this._groups[groupName]);

// hide menu items that user has requested to not include
if (!this._settings.get_boolean('show-' + optionName))
this._groups[groupName].actor.hide();
groupActor.hide();

if (!this._groups[groupName].status) {
this._groups[groupName].status = this._defaultLabel();
this._groups[groupName].actor.insert_child_at_index(this._groups[groupName].status, 4);
groupActor.insert_child_at_index(this._groups[groupName].status, 4);
this._groups[groupName].status.text = _('No Data');
}

Expand Down Expand Up @@ -504,13 +516,15 @@ var VitalsMenuButton = GObject.registerClass({
const sensorName = sensor.substr(5);
if(sensorName === 'gpu') {
for(let i = 1; i <= this._numGpus; i++)
this._groups[sensorName + '#' + i].visible = this._settings.get_boolean(sensor);
this._getActor(this._groups[sensorName + '#' + i]).visible = this._settings.get_boolean(sensor);
} else
this._groups[sensorName].visible = this._settings.get_boolean(sensor);
this._getActor(this._groups[sensorName]).visible = this._settings.get_boolean(sensor);
}

_positionInPanelChanged() {
this.container.get_parent().remove_child(this.container);
const parent = this.container.get_parent();
if (parent)
parent.remove_child(this.container);
let position = this._positionInPanel();

// allows easily addressable boxes
Expand Down
8 changes: 6 additions & 2 deletions menuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const MenuItem = GObject.registerClass({
this._valueLabel.set_y_expand(true);
this.add_child(this._valueLabel);

this.actor._delegate = this;
this._getActor()._delegate = this;
}

_getActor() {
return this.actor ?? this;
}

get checked() {
Expand All @@ -59,7 +63,7 @@ export const MenuItem = GObject.registerClass({

// prevents menu from being closed
activate(event) {
this._checked = !this._checked;
this._checked = !this._checked;
this._updateOrnament();
this.emit('toggle', event);
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Vitals",
"settings-schema": "org.gnome.shell.extensions.vitals",
"shell-version": [
"45", "46", "47", "48", "49"
"45", "46", "47", "48", "49", "50"
],
"url": "https://github.com/corecoding/Vitals",
"uuid": "Vitals@CoreCoding.com",
Expand Down
Loading