mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 00:14:14 +09:00
* replace global.log() with logError()
* remove run_dispose calls
This function should only be called from object system implementations.
https://gjs-docs.gnome.org/gobject20~2.0/gobject.object#method-run_dispose
* use pkexec instead of sudo for ipmi-sensors
This commit is contained in:
@@ -29,7 +29,7 @@ export default class CommandLineUtil {
|
||||
}
|
||||
});
|
||||
} catch(e){
|
||||
global.log(e.toString());
|
||||
logError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ const FreonMenuButton = GObject.registerClass(class Freon_FreonMenuButton extend
|
||||
|
||||
_initFreeipmiUtility() {
|
||||
if (this._settings.get_boolean('use-generic-freeipmi'))
|
||||
this._utils.freeipmi = new FreeipmiUtil();
|
||||
this._utils.freeipmi = new FreeipmiUtil(this._settings.get_string('exec-method-freeipmi'));
|
||||
}
|
||||
|
||||
_destroyFreeipmiUtility() {
|
||||
|
||||
@@ -4,22 +4,17 @@ import CommandLineUtil from './commandLineUtil.js';
|
||||
|
||||
export default class FreeipmiUtil extends CommandLineUtil {
|
||||
|
||||
constructor() {
|
||||
constructor(exec_method) {
|
||||
super();
|
||||
|
||||
const path = GLib.find_program_in_path('ipmi-sensors');
|
||||
// --comma-separated-output: pseudo csv output format, splitting on comma may be good enough for the values we read.
|
||||
this._argv = path ? [path, '--comma-separated-output'] : null;
|
||||
|
||||
if (this._argv) {
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
if (ExtensionUtils.getSettings().get_string('exec-method-freeipmi') === 'sudo')
|
||||
{
|
||||
const sudo_path = GLib.find_program_in_path('sudo');
|
||||
// --non-interactive: do not ask for password, return if no permission.
|
||||
this._argv = sudo_path ? [sudo_path, '--non-interactive'].concat(this._argv) : null;
|
||||
}
|
||||
if (this._argv && exec_method === 'sudo')
|
||||
{
|
||||
const pkexec_path = GLib.find_program_in_path('pkexec');
|
||||
this._argv = pkexec_path ? [pkexec_path].concat(this._argv) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export default class LiquidctlUtil extends CommandLineUtil {
|
||||
this._temp = null;
|
||||
this._rpm = null;
|
||||
this._volt = null;
|
||||
global.log('failed to process data from liquidctl: ' + e.toString());
|
||||
logError(e, 'failed to process data from liquidctl');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class NvmecliUtil {
|
||||
try {
|
||||
this._nvmeDevices = getNvmeData("list")["Devices"]
|
||||
} catch (e) {
|
||||
global.log('[FREON] Unable to find nvme devices: ' + e);
|
||||
logError(e, '[FREON] Unable to find nvme devices');
|
||||
}
|
||||
this._updated = true;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ export default class SensorsUtil extends CommandLineUtil {
|
||||
let errorRemoved = lineRemoved.replace(/ERROR.*Can't read/, "");
|
||||
errorRemoved = errorRemoved.replace(/ERROR.*I\/O error/, "");
|
||||
data = JSON.parse(errorRemoved);
|
||||
} catch (e) {
|
||||
global.log(e.toString());
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this._data = data;
|
||||
callback();
|
||||
|
||||
@@ -12,7 +12,7 @@ export default class SmartctlUtil {
|
||||
try {
|
||||
this._smartDevices = getSmartData("--scan")["devices"]
|
||||
} catch (e) {
|
||||
global.log('[FREON] Unable to find smart devices: ' + e);
|
||||
logError(e, '[FREON] Unable to find smart devices');
|
||||
}
|
||||
this._updated = true;
|
||||
}
|
||||
|
||||
@@ -82,13 +82,13 @@ export default class UDisks2 {
|
||||
// create the proxies object
|
||||
let driveProxy = new UDisksDriveProxy(Gio.DBus.system, "org.freedesktop.UDisks2", obj, function(res, error) {
|
||||
if (error) { //very unlikely - we even checked the interfaces before!
|
||||
global.log('[FREON] Could not create proxy on ' + obj + ':' + error);
|
||||
logError(error, '[FREON] Could not create proxy on ' + obj);
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
let ataProxy = new UDisksDriveAtaProxy(Gio.DBus.system, "org.freedesktop.UDisks2", obj, function(res, error) {
|
||||
if (error) {
|
||||
global.log('[FREON] Could not create proxy on ' + obj + ':' + error);
|
||||
logError(error, '[FREON] Could not create proxy on ' + obj);
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
@@ -101,20 +101,12 @@ export default class UDisks2 {
|
||||
callback(proxies.filter(function(a) { return a != null; }));
|
||||
});
|
||||
} catch (e) {
|
||||
global.log('[FREON] Could not find UDisks2 objects: ' + e);
|
||||
logError(e, '[FREON] Could not find UDisks2 objects');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
destroy(callback) {
|
||||
for (let proxy of this._udisksProxies){
|
||||
if(proxy.drive){
|
||||
proxy.drive.run_dispose();
|
||||
}
|
||||
if(proxy.ata){
|
||||
proxy.ata.run_dispose();
|
||||
}
|
||||
}
|
||||
this._udisksProxies = [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user