mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 00:14:14 +09:00
Change prefs to libadwaita, add battery sensors
This commit is contained in:
110
freon@UshakovVasilii_Github.yahoo.com/batteryUtil.js
Normal file
110
freon@UshakovVasilii_Github.yahoo.com/batteryUtil.js
Normal file
@@ -0,0 +1,110 @@
|
||||
import GLib from 'gi://GLib';
|
||||
|
||||
|
||||
export default class BatteryUtil {
|
||||
|
||||
constructor(callback) {
|
||||
this._bat_path = []; // Path to batteries for cat
|
||||
this._find_batteries();
|
||||
}
|
||||
|
||||
get available(){
|
||||
return (this._bat_path[0]) ? true : false;
|
||||
}
|
||||
|
||||
get energy() {
|
||||
let features = []
|
||||
this._bat_path.forEach((bat_path) => {
|
||||
let energy = parseFloat(this._get_sensor_data(bat_path, "energy_now"));
|
||||
energy /= 1000000.00;
|
||||
|
||||
let bat_name = bat_path.split('/').pop();
|
||||
let feature = {
|
||||
label: bat_name + " Energy",
|
||||
["power"]: energy
|
||||
};
|
||||
features.push(feature);
|
||||
});
|
||||
return features;
|
||||
}
|
||||
|
||||
get power() {
|
||||
let features = [];
|
||||
this._bat_path.forEach((bat_path) => {
|
||||
let power = parseFloat(this._get_sensor_data(bat_path, "power_now"));
|
||||
power /= 1000000.00;
|
||||
|
||||
let state = this._get_sensor_data(bat_path, "status");
|
||||
if (state.startsWith("Dis"))
|
||||
power *= -1;
|
||||
|
||||
let bat_name = bat_path.split('/').pop();
|
||||
let feature = {
|
||||
label: bat_name + " Power",
|
||||
["power"]: power
|
||||
};
|
||||
features.push(feature);
|
||||
})
|
||||
return features;
|
||||
}
|
||||
|
||||
get voltage() {
|
||||
let features = [];
|
||||
this._bat_path.forEach((bat_path) => {
|
||||
let voltage = parseFloat(this._get_sensor_data(bat_path, "voltage_now"));
|
||||
voltage /= 1000000.00;
|
||||
|
||||
let bat_name = bat_path.split('/').pop();
|
||||
let feature = {
|
||||
label: bat_name + " Voltage",
|
||||
["volt"]: voltage
|
||||
};
|
||||
features.push(feature);
|
||||
})
|
||||
return features;
|
||||
}
|
||||
|
||||
|
||||
destroy(callback) {
|
||||
this._bat_path = [];
|
||||
}
|
||||
|
||||
execute(callback) {
|
||||
}
|
||||
|
||||
_find_batteries() {
|
||||
const cmd = `find /sys/class/power_supply/ -type l -name "BAT*"`
|
||||
let cmd_res = []
|
||||
try {
|
||||
cmd_res = GLib.spawn_command_line_sync(cmd)
|
||||
} catch (e) {
|
||||
logError(e, `[FREON] failed to execute "find"`)
|
||||
}
|
||||
if (cmd_res[0] == true) {
|
||||
this._bat_path = new TextDecoder().decode( cmd_res[1] ).split('\n')
|
||||
let trailing_path = this._bat_path.pop()
|
||||
if (trailing_path.length > 1) // remove empty trailing Elements
|
||||
this._bat_path.push(trailing_path)
|
||||
}
|
||||
else {
|
||||
print(`"find" returned an error: ${cmd_res[2]}`)
|
||||
}
|
||||
}
|
||||
|
||||
_get_sensor_data(bat_path, sensor) {
|
||||
const path = `${bat_path}/${sensor}`
|
||||
const cmd = "cat " + path;
|
||||
|
||||
let cmd_res = []
|
||||
try {
|
||||
cmd_res = GLib.spawn_command_line_sync(cmd)
|
||||
} catch (e) {
|
||||
logError(e, `[FREON] failed to execute "cat"`)
|
||||
}
|
||||
if (cmd_res[0] == true)
|
||||
return new TextDecoder().decode(cmd_res[1])
|
||||
else
|
||||
return ""
|
||||
}
|
||||
|
||||
};
|
||||
@@ -23,6 +23,7 @@ import Udisks2Util from './udisks2.js';
|
||||
import HddtempUtil from './hddtempUtil.js';
|
||||
import SmartctlUtil from './smartctlUtil.js';
|
||||
import NvmecliUtil from './nvmecliUtil.js';
|
||||
import BatteryUtil from './batteryUtil.js';
|
||||
|
||||
import FreonItem from './freonItem.js';
|
||||
|
||||
@@ -76,6 +77,7 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
this._initSensorsUtility();
|
||||
this._initFreeipmiUtility();
|
||||
this._initLiquidctlUtility();
|
||||
this._initBatteryUtility();
|
||||
|
||||
this._initNvidiaUtility();
|
||||
this._initBumblebeeNvidiaUtility();
|
||||
@@ -88,6 +90,7 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
|
||||
let temperatureIcon = Gio.icon_new_for_string(path + '/icons/material-icons/material-temperature-symbolic.svg');
|
||||
let voltageIcon = Gio.icon_new_for_string(path + '/icons/freon-voltage-symbolic.svg');
|
||||
let batteryIcon = Gio.icon_new_for_string(path + '/icons/freon-battery-symbolic.svg');
|
||||
|
||||
this._sensorIcons = {
|
||||
'temperature' : temperatureIcon,
|
||||
@@ -98,6 +101,7 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
'voltage' : voltageIcon,
|
||||
'fan' : Gio.icon_new_for_string(path + '/icons/freon-fan-symbolic.svg'),
|
||||
'power' : voltageIcon,
|
||||
'battery' : batteryIcon,
|
||||
}
|
||||
|
||||
this._menuLayout = new St.BoxLayout();
|
||||
@@ -136,9 +140,9 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
this._addSettingChangedSignal('show-decimal-value', this._querySensors.bind(this));
|
||||
|
||||
this._addSettingChangedSignal('use-generic-lmsensors', this._sensorsUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('use-generic-freeipmi', this._freeipmiUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('exec-method-freeipmi', this._freeipmiUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('freeimpi-selected', this._freeipmiUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('use-generic-liquidctl', this._liquidctlUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('show-battery-stats', this._batteryUtilityChanged.bind(this));
|
||||
|
||||
this._addSettingChangedSignal('use-gpu-nvidia', this._nvidiaUtilityChanged.bind(this));
|
||||
this._addSettingChangedSignal('use-gpu-nvidiabumblebee', this._nvidiabumblebeeUtilityChanged.bind(this));
|
||||
@@ -153,6 +157,7 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
this._addSettingChangedSignal('show-rotationrate', this._rerender.bind(this));
|
||||
this._addSettingChangedSignal('show-voltage', this._rerender.bind(this));
|
||||
this._addSettingChangedSignal('show-power', this._rerender.bind(this));
|
||||
|
||||
|
||||
this._addSettingChangedSignal('group-temperature', this._rerender.bind(this))
|
||||
this._addSettingChangedSignal('group-rotationrate', this._rerender.bind(this))
|
||||
@@ -213,9 +218,21 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
right: Main.panel._rightBox
|
||||
};
|
||||
|
||||
let p = this.positionInPanel;
|
||||
let i = this._settings.get_int('panel-box-index');
|
||||
boxes[p].insert_child_at_index(this.container, i);
|
||||
let p = this._settings.get_int('position-in-panel');
|
||||
|
||||
console.debug(p)
|
||||
|
||||
switch (p) {
|
||||
case 0:
|
||||
boxes['left'].insert_child_at_index(this.container, i); break;
|
||||
case 1:
|
||||
boxes['center'].insert_child_at_index(this.container, i); break;
|
||||
case 2:
|
||||
default:
|
||||
boxes['right'].insert_child_at_index(this.container, i); break;
|
||||
}
|
||||
//boxes[p].insert_child_at_index(this.container, i);
|
||||
}
|
||||
|
||||
_showIconOnPanelChanged(){
|
||||
@@ -258,14 +275,16 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_initFreeipmiUtility() {
|
||||
if (this._settings.get_boolean('use-generic-freeipmi'))
|
||||
{
|
||||
let exec_method = this._settings.get_string('exec-method-freeipmi');
|
||||
let exec_method = this._settings.get_int('freeimpi-selected');
|
||||
if (exec_method != 0) {
|
||||
try {
|
||||
this._utils.freeipmi = new FreeipmiUtil(exec_method);
|
||||
if (exec_method == 1)
|
||||
this._utils.freeipmi = new FreeipmiUtil("direct");
|
||||
else if (exec_method == 2)
|
||||
this._utils.freeipmi = new FreeipmiUtil("pkexec");
|
||||
} catch (e) {
|
||||
if (exec_method != 'direct') {
|
||||
this._settings.set_string('exec-method-freeipmi', 'direct');
|
||||
if (exec_method == 2) {
|
||||
this._settings.set_int('freeimpi-selected', 1);
|
||||
this._freeipmiUtilityChanged();
|
||||
}
|
||||
}
|
||||
@@ -305,6 +324,25 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
this._updateUI(true);
|
||||
}
|
||||
|
||||
_initBatteryUtility() {
|
||||
if (this._settings.get_boolean("show-battery-stats"))
|
||||
this._utils.battery = new BatteryUtil();
|
||||
}
|
||||
|
||||
_destroyBatteryUtility() {
|
||||
if (this._utils.battery) {
|
||||
this._utils.battery.destroy();
|
||||
delete this._utils.battery;
|
||||
}
|
||||
}
|
||||
|
||||
_batteryUtilityChanged() {
|
||||
this._destroyBatteryUtility();
|
||||
this._initBatteryUtility();
|
||||
this._querySensors();
|
||||
this._updateUI(true);
|
||||
}
|
||||
|
||||
_initNvidiaUtility() {
|
||||
if (this._settings.get_boolean('use-gpu-nvidia'))
|
||||
this._utils.nvidia = new NvidiaUtil();
|
||||
@@ -471,6 +509,8 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
this._destroySmartctlUtility();
|
||||
this._destroyNvmecliUtility();
|
||||
|
||||
this._destroyBatteryUtility();
|
||||
|
||||
GLib.Source.remove(this._timeoutId);
|
||||
GLib.Source.remove(this._updateUITimeoutId);
|
||||
|
||||
@@ -549,8 +589,10 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
fanInfo = fanInfo.concat(this._utils.sensors.rpm);
|
||||
if (this._settings.get_boolean('show-voltage'))
|
||||
voltageInfo = voltageInfo.concat(this._utils.sensors.volt);
|
||||
if (this._settings.get_boolean('show-power'))
|
||||
if (this._settings.get_boolean('show-power')) {
|
||||
powerInfo = powerInfo.concat(this._utils.sensors.power);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this._utils.freeipmi && this._utils.freeipmi.available) {
|
||||
@@ -571,6 +613,12 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
voltageInfo = voltageInfo.concat(this._utils.liquidctl.volt);
|
||||
}
|
||||
|
||||
if (this._utils.battery && this._utils.battery.available) {
|
||||
if (this._settings.get_boolean('show-battery-stats')) {
|
||||
powerInfo = powerInfo.concat(this._utils.battery.power)
|
||||
}
|
||||
}
|
||||
|
||||
if (this._utils.nvidia && this._utils.nvidia.available)
|
||||
if (this._settings.get_boolean('show-temperature'))
|
||||
gpuTempInfo = gpuTempInfo.concat(this._utils.nvidia.temp);
|
||||
@@ -733,9 +781,12 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
|
||||
for (let power of powerInfo){
|
||||
const unit = this._settings.get_boolean('show-power-unit') ? _('W'): '';
|
||||
|
||||
let _icon = 'power';
|
||||
if (power.label.startsWith("BAT")) {
|
||||
_icon = 'battery';
|
||||
}
|
||||
sensors.push({
|
||||
icon: 'power',
|
||||
icon: _icon,
|
||||
type: 'power',
|
||||
label: power.label,
|
||||
value: _("%s%.2f%s").format(((power.power >= 0) ? '+' : ''),
|
||||
@@ -959,27 +1010,32 @@ class FreonMenuButton extends PanelMenu.Button {
|
||||
}
|
||||
|
||||
_formatTemp(value) {
|
||||
if(value === null)
|
||||
let unit_type = this._settings.get_int('unit');
|
||||
let show_unit = this._settings.get_boolean('show-temperature-unit');
|
||||
|
||||
if(value === null) {
|
||||
return 'N/A';
|
||||
if (this._settings.get_string('unit')=='fahrenheit'){
|
||||
value = this._toFahrenheit(value);
|
||||
}
|
||||
|
||||
let format = '%.1f';
|
||||
if (!this._settings.get_boolean('show-decimal-value')){
|
||||
format = '%.0f';
|
||||
}
|
||||
format += '%s';
|
||||
|
||||
if(this._settings.get_boolean('show-temperature-unit')){
|
||||
return format.format(value, (this._settings.get_string('unit')=='fahrenheit') ? "\u00b0F" : "\u00b0C" );
|
||||
} else {
|
||||
return format.format(value, "");
|
||||
if (unit_type == 1) {
|
||||
value = this._toFahrenheit(value);
|
||||
}
|
||||
|
||||
if (show_unit) {
|
||||
if (unit_type == 0) {
|
||||
format += "\u00b0C";
|
||||
} else if (unit_type == 1) {
|
||||
format += "\u00b0F";
|
||||
}
|
||||
}
|
||||
return format.format(value);
|
||||
}
|
||||
|
||||
get positionInPanel(){
|
||||
return this._settings.get_string('position-in-panel');
|
||||
}
|
||||
}
|
||||
|
||||
export default class extends Extension {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
id="svg7384"
|
||||
version="1.1"
|
||||
height="16"
|
||||
width="16"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<metadata
|
||||
id="metadata90">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title>Gnome Symbolic Icon Theme</dc:title>
|
||||
<cc:license
|
||||
rdf:resource="http://artlibre.org/licence/lal" />
|
||||
</cc:Work>
|
||||
<cc:License
|
||||
rdf:about="http://artlibre.org/licence/lal">
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" />
|
||||
<cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Notice" />
|
||||
<cc:requires
|
||||
rdf:resource="http://creativecommons.org/ns#Attribution" />
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<title
|
||||
id="title9167">Gnome Symbolic Icon Theme</title>
|
||||
<defs
|
||||
id="defs7386" />
|
||||
<path
|
||||
style="fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:0.694338"
|
||||
d="M 4.5,9.5 V 10 h 3 l -3,2.482247 C 4,13 4,13 4,13.5 V 14 h 0.5 c 1.0032668,0 1,0 4,-2.5 3,-2.5 3,-2.5 3,-3 V 8 H 9 C 12,5.5 12,5.5 12,4.5 V 4 h -0.5 c -0.998962,0 -0.995461,0 -4,2.5 -3.0018577,2.497769 -3,2.5 -3,3 z"
|
||||
id="path3898" />
|
||||
<path
|
||||
style="fill:#bfbfbf;fill-opacity:1;stroke-width:0.92582"
|
||||
d="M 14,2 V 16 H 2 V 2 H 3 V 15 H 13 V 3 H 3 V 2 H 6 V 1 h 4 v 1"
|
||||
id="path1" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
@@ -1,230 +1,188 @@
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
import Gtk from 'gi://Gtk?version=4.0';
|
||||
import Gio from 'gi://Gio'
|
||||
import Gtk from 'gi://Gtk'
|
||||
import Adw from 'gi://Adw'
|
||||
|
||||
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||
|
||||
const modelColumn = {
|
||||
label: 0,
|
||||
separator: 1
|
||||
}
|
||||
|
||||
var FreonPrefsWidget = new GObject.registerClass(class Freon_FreonPrefsWidget extends Gtk.Grid {
|
||||
export default class FreonPreferences extends ExtensionPreferences {
|
||||
|
||||
constructor(settings) {
|
||||
super();
|
||||
this.margin = this.row_spacing = this.column_spacing = 20;
|
||||
fillPreferencesWindow(window) {
|
||||
window.set_default_size(1010, 800);
|
||||
|
||||
this._settings = settings;
|
||||
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
this._addLabel({
|
||||
label: _('Display Options'),
|
||||
y : i++, x : j
|
||||
const grid = new Gtk.Grid({
|
||||
column_homogeneous: true,
|
||||
column_spacing: 10,
|
||||
row_homogeneous: false,
|
||||
});
|
||||
|
||||
this._addLabel({
|
||||
label: _('Poll Sensors Every (sec)'),
|
||||
y : i, x : j
|
||||
this._settings = this.getSettings()
|
||||
const page = new Adw.PreferencesPage({
|
||||
title: _('General'),
|
||||
icon_name: 'dialog-information-symbolic',
|
||||
|
||||
});
|
||||
|
||||
const display_options = this._create_display_options();
|
||||
const generic_sensor_providers = this._create_generic_sensor_providers();
|
||||
const gpu_sensor_providers = this._create_gpu_sensor_providers();
|
||||
const drive_sensor_providers = this._create_drive_sensor_providers();
|
||||
const show_sensors = this._create_show_sensors();
|
||||
const item_group = this._create_item_grouping();
|
||||
|
||||
let updateTime = Gtk.SpinButton.new_with_range (1, 60, 1);
|
||||
this.attach(updateTime, j + 1, i++, 1, 1);
|
||||
this._settings.bind('update-time', updateTime, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||
grid.attach(display_options, 0, 0, 1, 12);
|
||||
grid.attach(generic_sensor_providers, 1, 0, 1, 4);
|
||||
grid.attach(gpu_sensor_providers, 1, 4, 1, 4);
|
||||
grid.attach(drive_sensor_providers, 1, 8, 1, 4);
|
||||
grid.attach(show_sensors, 2, 0, 1, 6);
|
||||
grid.attach(item_group, 2, 6, 1, 4);
|
||||
|
||||
this._addComboBox({
|
||||
label: _('Position on Panel'),
|
||||
items : {left : _('Left'), center : _('Center'), right : _('Right')},
|
||||
key: 'position-in-panel', y : i++, x : j
|
||||
});
|
||||
const widget = new Adw.PreferencesGroup({
|
||||
hexpand: true,
|
||||
vexpand: true,
|
||||
})
|
||||
widget.add(grid);
|
||||
|
||||
this._addLabel({
|
||||
label: _('Index on Panel'),
|
||||
y : i, x : j
|
||||
});
|
||||
page.add(widget);
|
||||
|
||||
let panelBoxIndex = Gtk.SpinButton.new_with_range (-1, 20, 1);
|
||||
this.attach(panelBoxIndex, j + 1, i++, 1, 1);
|
||||
this._settings.bind('panel-box-index', panelBoxIndex, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
this._addSwitch({key : 'show-icon-on-panel', y : i++, x : j,
|
||||
label : _('Show Icon on Panel')});
|
||||
|
||||
this._addComboBox({
|
||||
label: _('Temperature Unit'),
|
||||
items : {centigrade : _("\u00b0C"), fahrenheit : _("\u00b0F")},
|
||||
key: 'unit', y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'show-temperature-unit', y : i++, x : j,
|
||||
label : _('Show Temperature Unit')});
|
||||
|
||||
this._addSwitch({key : 'show-rotationrate-unit', y : i++, x : j,
|
||||
label : _('Show Rotation Rate Unit')});
|
||||
|
||||
this._addSwitch({key : 'show-voltage-unit', y : i++, x : j,
|
||||
label : _('Show Voltage Unit')});
|
||||
|
||||
this._addSwitch({key : 'show-power-unit', y : i++, x : j,
|
||||
label : _('Show Power Unit')});
|
||||
|
||||
this._addSwitch({key : 'show-decimal-value', y : i++, x : j,
|
||||
label : _('Show Decimal Values'),
|
||||
help : _("Show additionnal digits after decimal point")});
|
||||
|
||||
i = 0;
|
||||
j = 2;
|
||||
|
||||
this._addLabel({
|
||||
label: _('Generic Sensor Providers'),
|
||||
y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'use-generic-lmsensors', y : i++, x : j,
|
||||
label : 'lm-sensors',
|
||||
help : _('Read sensors from lm-sensors')});
|
||||
|
||||
this._addSwitch({key : 'use-generic-freeipmi', y : i, x : j,
|
||||
label : 'FreeIPMI',
|
||||
help : _('Read sensors using ipmi-sensors from FreeIPMI')});
|
||||
|
||||
this._addComboBox({
|
||||
items : {
|
||||
'direct' : _('Direct'),
|
||||
'pkexec' : 'pkexec' },
|
||||
key: 'exec-method-freeipmi', y : i++, x : j + 1,
|
||||
label: ''
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'use-generic-liquidctl', y : i++, x : j,
|
||||
label : 'liquidctl',
|
||||
help : _('Read sensors from liquidctl (requires v1.7.0 or later)')});
|
||||
|
||||
this._addLabel({
|
||||
label: _('GPU Sensor Providers'),
|
||||
y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'use-gpu-nvidia', y : i++, x : j,
|
||||
label : 'Nvidia'});
|
||||
|
||||
this._addSwitch({key : 'use-gpu-bumblebeenvidia', y : i++, x : j,
|
||||
label : 'Bumblebee + Nvidia'});
|
||||
|
||||
this._addSwitch({key : 'use-gpu-aticonfig', y : i++, x : j,
|
||||
label : 'Catalyst'});
|
||||
|
||||
this._addLabel({
|
||||
label: _('Drive Sensor Providers'),
|
||||
y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'use-drive-udisks2', y : i++, x : j,
|
||||
label : 'Udisks2'});
|
||||
|
||||
this._addSwitch({key : 'use-drive-hddtemp', y : i++, x : j,
|
||||
label : 'Hddtemp'});
|
||||
|
||||
this._addSwitch({key : 'use-drive-smartctl', y : i++, x : j,
|
||||
label : 'smartctl',
|
||||
help : _('Read drive sensors using smartctl from smartmontools')});
|
||||
|
||||
this._addSwitch({key : 'use-drive-nvmecli', y : i++, x : j,
|
||||
label : 'nvme-cli'});
|
||||
|
||||
i = 0;
|
||||
j = 5;
|
||||
|
||||
this._addLabel({
|
||||
label: _('Show Sensors'),
|
||||
y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'show-temperature', y : i++, x : j,
|
||||
label : _('Temperature')});
|
||||
|
||||
this._addSwitch({key : 'show-rotationrate', y : i++, x : j,
|
||||
label : _('Rotation Rate')});
|
||||
|
||||
this._addSwitch({key : 'show-voltage', y : i++, x : j,
|
||||
label : _('Voltage')});
|
||||
|
||||
this._addSwitch({key : 'show-power', y : i++, x : j,
|
||||
label : _('Power')});
|
||||
|
||||
this._addLabel({
|
||||
label: _('Group Items'),
|
||||
y : i++, x : j
|
||||
});
|
||||
|
||||
this._addSwitch({key : 'group-temperature', y : i++, x : j,
|
||||
label : _('Temperature'),
|
||||
help : _("Group three or more temperature sensors")});
|
||||
|
||||
this._addSwitch({key : 'group-rotationrate', y : i++, x : j,
|
||||
label : _('Rotation Rate'),
|
||||
help : _("Group three or more rotation rate sensors")});
|
||||
|
||||
this._addSwitch({key : 'group-voltage', y : i++, x : j,
|
||||
label : _('Voltage'),
|
||||
help : _("Group three or more voltage sensors")});
|
||||
}
|
||||
|
||||
_addLabel(params){
|
||||
let lbl = new Gtk.Label({label: params.label,halign : Gtk.Align.END});
|
||||
this.attach(lbl, params.x, params.y, 1, 1);
|
||||
|
||||
if(params.help){
|
||||
lbl.set_tooltip_text(params.help);
|
||||
}
|
||||
window.add(page);
|
||||
}
|
||||
|
||||
_addSwitch(params){
|
||||
this._addLabel(params);
|
||||
|
||||
let sw = new Gtk.Switch({halign : Gtk.Align.END, valign : Gtk.Align.CENTER});
|
||||
this.attach(sw, params.x + 1, params.y, 1, 1);
|
||||
_create_display_options() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('Display Options'),
|
||||
width_request: 320,
|
||||
})
|
||||
|
||||
const sensor_poll_intervall = new Adw.SpinRow({
|
||||
title: _('Sensor Polling Interval'),
|
||||
adjustment: new Gtk.Adjustment({
|
||||
lower: 1,
|
||||
upper: 60,
|
||||
value: 5,
|
||||
step_increment: 1,
|
||||
})
|
||||
})
|
||||
this._settings.bind('update-time', sensor_poll_intervall, 'value', Gio.SettingsBindFlags.DEFAULT)
|
||||
group.add(sensor_poll_intervall)
|
||||
|
||||
if(params.help){
|
||||
sw.set_tooltip_text(params.help);
|
||||
}
|
||||
const position_in_panel = new Adw.ComboRow({
|
||||
title: _('Panel Position'),
|
||||
model: new Gtk.StringList({strings: ["Left", "Center", "Right"] }),
|
||||
})
|
||||
this._settings.bind("position-in-panel", position_in_panel, "selected", Gio.SettingsBindFlags.NO_SENSETIVITY);
|
||||
group.add(position_in_panel)
|
||||
|
||||
this._settings.bind(params.key, sw, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
const index_on_panel = new Adw.SpinRow({
|
||||
title: _('Index on Panel'),
|
||||
adjustment: new Gtk.Adjustment({
|
||||
lower: -1,
|
||||
upper: 25,
|
||||
value: 1,
|
||||
step_increment: 1,
|
||||
})
|
||||
});
|
||||
group.add(index_on_panel);
|
||||
this._settings.bind('panel-box-index', index_on_panel, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
group.add(this._addSwitch("Show Icon on Panel", "show-icon-on-panel"));
|
||||
|
||||
const unit_setting = new Adw.ComboRow({
|
||||
title: _('Temperature Unit'),
|
||||
model: new Gtk.StringList({strings: ["\u00b0C", "\u00b0F"]}),
|
||||
});
|
||||
this._settings.bind("unit", unit_setting, "selected", Gio.SettingsBindFlags.NO_SENSETIVITY);
|
||||
group.add(unit_setting);
|
||||
|
||||
group.add(this._addSwitch("Show Temperature Unit", "show-temperature-unit"));
|
||||
group.add(this._addSwitch("Show Rotation Rate Unit", "show-rotationrate-unit"));
|
||||
group.add(this._addSwitch("Show Voltage Unit", "show-voltage-unit"));
|
||||
group.add(this._addSwitch("Show Power Unit", "show-power-unit"));
|
||||
group.add(this._addSwitch("Show Decimal Values", "show-decimal-value", "Show additionnal digits after decimal point"));
|
||||
return group;
|
||||
}
|
||||
|
||||
_addComboBox(params){
|
||||
let model = new Gtk.ListStore();
|
||||
model.set_column_types([GObject.TYPE_STRING, GObject.TYPE_STRING]);
|
||||
|
||||
let combobox = new Gtk.ComboBox({model: model});
|
||||
let renderer = new Gtk.CellRendererText();
|
||||
combobox.pack_start(renderer, true);
|
||||
combobox.add_attribute(renderer, 'text', 1);
|
||||
|
||||
for(let k in params.items){
|
||||
model.set(model.append(), [0, 1], [k, params.items[k]]);
|
||||
}
|
||||
|
||||
combobox.set_active(Object.keys(params.items).indexOf(this._settings.get_string(params.key)));
|
||||
|
||||
combobox.connect('changed', (entry) => {
|
||||
let [success, iter] = combobox.get_active_iter();
|
||||
if (!success)
|
||||
return;
|
||||
this._settings.set_string(params.key, model.get_value(iter, 0))
|
||||
_create_generic_sensor_providers() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('Generic Sensor Providers'),
|
||||
width_request: 320,
|
||||
});
|
||||
|
||||
this._addLabel(params);
|
||||
group.add(this._addSwitch("lm-sensors", "use-generic-lmsensors", "Read sensors from lm-sensors"));
|
||||
group.add(this._addSwitch("liquidctl", "use-generic-liquidctl", "Read sensors from liquidctl (v1.7.0+)"));
|
||||
|
||||
this.attach(combobox, params.x + 1, params.y, 1, 1);
|
||||
const freeimpi = new Adw.ComboRow({
|
||||
title: _('FreeIMPI'),
|
||||
model: new Gtk.StringList({strings: ["Disabled", "Direct", "pkexec"] }),
|
||||
selected: this._settings.get_int("freeimpi-selected"),
|
||||
subtitle: "Read sensors using ipmi-sensors from FreeIPMI"
|
||||
});
|
||||
this._settings.bind("freeimpi-selected", freeimpi, "selected", Gio.SettingsBindFlags.NO_SENSETIVITY);
|
||||
group.add(freeimpi);
|
||||
|
||||
return group;
|
||||
}
|
||||
});
|
||||
|
||||
export default class extends ExtensionPreferences {
|
||||
_create_gpu_sensor_providers() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('GPU Sensor Providers'),
|
||||
width_request: 320,
|
||||
});
|
||||
group.add(this._addSwitch("Nvidia", "use-gpu-nvidia"));
|
||||
group.add(this._addSwitch("Bumblebee + Nvidia", "use-gpu-bumblebeenvidia"));
|
||||
group.add(this._addSwitch("Catalyst", "use-gpu-aticonfig"));
|
||||
|
||||
getPreferencesWidget() {
|
||||
return new FreonPrefsWidget(this.getSettings());
|
||||
return group;
|
||||
}
|
||||
|
||||
_create_drive_sensor_providers() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('Drive Sensor Providers'),
|
||||
width_request: 320,
|
||||
});
|
||||
group.add(this._addSwitch("Udisks2", "use-drive-udisks2"));
|
||||
group.add(this._addSwitch("Hddtemp", "use-drive-hddtemp"));
|
||||
group.add(this._addSwitch("smartctl", "use-drive-smartctl", "Read drive sensors using smartctl from smartmontools"));
|
||||
group.add(this._addSwitch("nvme-cli", "use-drive-nvmecli"));
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
_create_show_sensors() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('Show Sensors'),
|
||||
width_request: 320,
|
||||
})
|
||||
|
||||
group.add(this._addSwitch("Temperature", "show-temperature"));
|
||||
group.add(this._addSwitch("Rotation Rate", "show-rotationrate"));
|
||||
group.add(this._addSwitch("Voltage", "show-voltage"));
|
||||
group.add(this._addSwitch("Power", "show-power"));
|
||||
group.add(this._addSwitch("Battery", "show-battery-stats"));
|
||||
return group
|
||||
}
|
||||
|
||||
_create_item_grouping() {
|
||||
const group = new Adw.PreferencesGroup({
|
||||
title: _('Group Items'),
|
||||
width_request: 320,
|
||||
description: "Group three or more sensor of the same type",
|
||||
})
|
||||
group.add(this._addSwitch("Temperature", "group-temperature"));
|
||||
group.add(this._addSwitch("Rotation Rate", "group-rotationrate"));
|
||||
group.add(this._addSwitch("Voltage", "group-voltage"));
|
||||
return group;
|
||||
}
|
||||
|
||||
_addSwitch(title, key, help = "") {
|
||||
const sw = new Adw.SwitchRow({
|
||||
title: _(title),
|
||||
active: this._settings.get_boolean(key),
|
||||
subtitle: help
|
||||
});
|
||||
this._settings.bind(key, sw, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
return sw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
<description>This is the seconds after CPU temperature extension updates the data from the system</description>
|
||||
</key>
|
||||
|
||||
<key type="s" name="position-in-panel">
|
||||
<default>'right'</default>
|
||||
<key type="i" name="position-in-panel">
|
||||
<default>2</default>
|
||||
<summary>Position in Panel</summary>
|
||||
<description>Position in Panel ('left', 'center', 'right')</description>
|
||||
<description>Position in Panel ('Left', 'Center', 'Right')</description>
|
||||
</key>
|
||||
|
||||
<key name="panel-box-index" type="i">
|
||||
@@ -33,22 +33,22 @@
|
||||
<description>Show sensor icon on top panel</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="show-temperature">
|
||||
<default>true</default>
|
||||
<summary>Display Temperature</summary>
|
||||
<description>Display temperature</description>
|
||||
</key>
|
||||
|
||||
<key type="s" name="unit">
|
||||
<default>'centigrade'</default>
|
||||
<summary>Unit</summary>
|
||||
<description>The unit ('centigrade' or 'fahrenheit') the extension should display the temperature in</description>
|
||||
<key type="i" name="unit">
|
||||
<default>0</default>
|
||||
<summary>Select centigrade or fahrenheit</summary>
|
||||
<description>Choose wether to display the Number for centigrade or fahrenheit</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="show-temperature-unit">
|
||||
<default>true</default>
|
||||
<summary>Show degrees celsius/fahrenheit on Panel</summary>
|
||||
<description>Show degrees celsius/fahrenheit on Panel</description>
|
||||
<summary>Enable the display of Temperature Unit on Panel</summary>
|
||||
<description>Enable the display of Temperature Unit on Panel</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="show-temperature">
|
||||
<default>true</default>
|
||||
<summary>Show RPM on Panel</summary>
|
||||
<description>Show RPM on Panel</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="show-rotationrate-unit">
|
||||
@@ -87,14 +87,14 @@
|
||||
<description>Read sensors from lm-sensors</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="use-generic-freeipmi">
|
||||
<default>false</default>
|
||||
<summary>Read sensors using ipmi-sensors from FreeIPMI</summary>
|
||||
<description>Read sensors using ipmi-sensors from FreeIPMI</description>
|
||||
<key type="i" name="freeimpi-selected">
|
||||
<default>0</default>
|
||||
<summary>Selected element number in the FreeIMPI-Dropdown</summary>
|
||||
<description>Selected element number in the FreeIMPI-Dropdown</description>
|
||||
</key>
|
||||
|
||||
<key type="s" name="exec-method-freeipmi">
|
||||
<default>'direct'</default>
|
||||
<default>'Disabled'</default>
|
||||
<summary>Method to run FreeIPMI utility</summary>
|
||||
<description>Method to run FreeIPMI utility</description>
|
||||
</key>
|
||||
@@ -158,6 +158,12 @@
|
||||
<summary>Display voltage</summary>
|
||||
<description>Display voltage of various components</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="show-battery-stats">
|
||||
<default>true</default>
|
||||
<summary>Show battery statistics</summary>
|
||||
<description>If a battery is available, battery stats will be retrieved</description>
|
||||
</key>
|
||||
|
||||
<key type="b" name="group-temperature">
|
||||
<default>true</default>
|
||||
|
||||
Reference in New Issue
Block a user