update for gnome-shell 3.32 #126

This commit is contained in:
UshakovVasilii
2019-03-20 10:28:11 +03:00
parent b08fce4ac8
commit 6f9d334cef
12 changed files with 178 additions and 209 deletions

View File

@@ -1,18 +1,15 @@
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var AticonfigUtil = new Lang.Class({
Name: 'AticonfigUtil',
Extends: CommandLineUtil.CommandLineUtil,
var AticonfigUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
this.parent();
constructor() {
super();
let path = GLib.find_program_in_path('aticonfig');
this._argv = path ? [path, '--odgt'] : null;
},
}
/*
Default Adapter - AMD Radeon R9 200 Series
@@ -39,4 +36,4 @@ var AticonfigUtil = new Lang.Class({
return [{ label : label.trim(), temp : temp}];
}
});
};

View File

@@ -1,16 +1,13 @@
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var BumblebeeNvidiaUtil = new Lang.Class({
Name: 'BumblebeeNvidiaUtil',
Extends: CommandLineUtil.CommandLineUtil,
var BumblebeeNvidiaUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
this.parent();
constructor() {
super();
// optirun nvidia-smi -q -d TEMPERATURE
this._path = GLib.find_program_in_path('optirun');
this._argv = this._path ? [this._path, 'nvidia-smi', '-q', '-d', 'TEMPERATURE'] : null;
@@ -35,7 +32,7 @@ var BumblebeeNvidiaUtil = new Lang.Class({
lockFilePath).monitor_file(Gio.FileMonitorFlags.NONE, null
);
this._lockMonitor.id = this._lockMonitor.connect(
'changed', Lang.bind(this, this._statusChanged)
'changed', this._statusChanged.bind(this)
);
// Check if the lock file already exists
@@ -44,9 +41,9 @@ var BumblebeeNvidiaUtil = new Lang.Class({
this._detectLabel();
this._active = true;
}
},
}
_detectLabel: function() {
_detectLabel() {
// optirun nvidia-smi -L
// GPU 0: GeForce GT 525M (UUID: GPU-...)
for (let line of GLib.spawn_command_line_sync(this._path + " nvidia-smi -L")){
@@ -58,9 +55,9 @@ var BumblebeeNvidiaUtil = new Lang.Class({
break;
}
}
},
}
_statusChanged: function(monitor, a_file, other_file, event_type) {
_statusChanged(monitor, a_file, other_file, event_type) {
if (event_type == Gio.FileMonitorEvent.CREATED) {
if(this._argv && !this._label)
this._detectLabel();
@@ -68,14 +65,14 @@ var BumblebeeNvidiaUtil = new Lang.Class({
} else if (event_type == Gio.FileMonitorEvent.DELETED) {
this._active = false;
}
},
}
execute: function(callback) {
execute(callback) {
if(this._active)
this.parent(callback);
else
this._output = [];
},
}
get temp() {
let key = 'bumblebee-nvidia'
@@ -95,11 +92,11 @@ var BumblebeeNvidiaUtil = new Lang.Class({
}
}
return [{label: key, temp: null, displayName: label}];
},
}
destroy: function(){
destroy(){
this.parent();
this._lockMonitor.disconnect(this._lockMonitor.id);
}
});
};

View File

@@ -1,17 +1,15 @@
const ByteArray = imports.byteArray;
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
var CommandLineUtil = new Lang.Class({
Name: 'CommandLineUtil',
var CommandLineUtil = class {
_init: function(){
constructor(){
this._argv = null;
this._updated = false;
},
}
execute: function(callback) {
execute(callback) {
try{
this._callback = callback;
let [exit, pid, stdinFd, stdoutFd, stderrFd] =
@@ -28,7 +26,7 @@ var CommandLineUtil = new Lang.Class({
GLib.close(stdinFd);
let childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, Lang.bind(this, function(pid, status, requestObj) {
let childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, (pid, status, requestObj) => {
let output = [];
let [line, size] = [null, 0];
@@ -48,26 +46,26 @@ var CommandLineUtil = new Lang.Class({
this._output = output;
this._updated = true;
callback();
}));
});
} catch(e){
global.log(e.toString());
}
},
}
get available(){
return this._argv != null;
},
}
get updated (){
return this._updated;
},
}
set updated (updated){
this._updated = updated;
},
}
destroy: function(){
destroy(){
this._argv = null;
}
});
};

View File

@@ -1,5 +1,4 @@
const St = imports.gi.St;
const Lang = imports.lang;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Main = imports.ui.main;
@@ -47,12 +46,10 @@ function _makeLogFunction(prefix) {
}
}
var FreonMenuButton = new Lang.Class({
Name: 'FreonMenuButton',
Extends: PanelMenu.Button,
const FreonMenuButton = class extends PanelMenu.Button {
_init: function(){
this.parent(St.Align.START);
constructor(){
super(St.Align.START);
this._settings = Convenience.getSettings();
@@ -98,33 +95,33 @@ var FreonMenuButton = new Lang.Class({
this.actor.add_actor(this._menuLayout);
this._settingChangedSignals = [];
this._addSettingChangedSignal('update-time', Lang.bind(this, this._updateTimeChanged));
this._addSettingChangedSignal('unit', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-icon-on-panel', Lang.bind(this, this._showIconOnPanelChanged));
this._addSettingChangedSignal('hot-sensors', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-decimal-value', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-fan-rpm', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-voltage', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('drive-utility', Lang.bind(this, this._driveUtilityChanged));
this._addSettingChangedSignal('gpu-utility', Lang.bind(this, this._gpuUtilityChanged));
this._addSettingChangedSignal('position-in-panel', Lang.bind(this, this._positionInPanelChanged));
this._addSettingChangedSignal('group-temperature', Lang.bind(this, this._querySensors))
this._addSettingChangedSignal('group-voltage', Lang.bind(this, this._rerender))
this._addSettingChangedSignal('update-time', this._updateTimeChanged.bind(this));
this._addSettingChangedSignal('unit', this._querySensors.bind(this));
this._addSettingChangedSignal('show-icon-on-panel', this._showIconOnPanelChanged.bind(this));
this._addSettingChangedSignal('hot-sensors', this._querySensors.bind(this));
this._addSettingChangedSignal('show-decimal-value', this._querySensors.bind(this));
this._addSettingChangedSignal('show-fan-rpm', this._querySensors.bind(this));
this._addSettingChangedSignal('show-voltage', this._querySensors.bind(this));
this._addSettingChangedSignal('drive-utility', this._driveUtilityChanged.bind(this));
this._addSettingChangedSignal('gpu-utility', this._gpuUtilityChanged.bind(this));
this._addSettingChangedSignal('position-in-panel', this._positionInPanelChanged.bind(this));
this._addSettingChangedSignal('group-temperature', this._querySensors.bind(this))
this._addSettingChangedSignal('group-voltage', this._rerender.bind(this))
this.connect('destroy', Lang.bind(this, this._onDestroy));
this.connect('destroy', this._onDestroy.bind(this));
// don't postprone the first call by update-time.
this._querySensors();
this._addTimer();
this._updateUITimeoutId = Mainloop.timeout_add(250, Lang.bind(this, function (){
this._updateUITimeoutId = Mainloop.timeout_add(250, () => {
this._updateUI();
// readd to update queue
return true;
}));
},
});
}
_createHotItem: function(s, showIcon, gicon){
_createHotItem(s, showIcon, gicon){
if(showIcon){
let i = new St.Icon({ style_class: 'system-status-icon'});
this._hotIcons[s] = i;
@@ -138,20 +135,20 @@ var FreonMenuButton = new Lang.Class({
y_align: Clutter.ActorAlign.CENTER});
this._hotLabels[s] = l;
this._menuLayout.add(l);
},
}
_createInitialIcon: function() {
_createInitialIcon() {
this._initialIcon = new St.Icon({ style_class: 'system-status-icon'});
this._initialIcon.gicon = this._sensorIcons['gpu-temperature'];
this._menuLayout.add(this._initialIcon);
},
}
_rerender : function(){
_rerender(){
this._needRerender = true;
this._querySensors();
},
}
_positionInPanelChanged : function(){
_positionInPanelChanged(){
this.container.get_parent().remove_actor(this.container);
// small HACK with private boxes :)
@@ -163,9 +160,9 @@ var FreonMenuButton = new Lang.Class({
let p = this.positionInPanel;
boxes[p].insert_child_at_index(this.container, p == 'right' ? 0 : -1)
},
}
_showIconOnPanelChanged : function(){
_showIconOnPanelChanged(){
if(this._settings.get_boolean('show-icon-on-panel')) {
let index = 0;
for(let k in this._hotLabels){
@@ -180,38 +177,38 @@ var FreonMenuButton = new Lang.Class({
this._hotIcons[k].destroy();
this._hotIcons = {};
}
},
}
_driveUtilityChanged : function(){
_driveUtilityChanged(){
this._destroyDriveUtility();
this._initDriveUtility();
this._querySensors();
},
}
_initDriveUtility : function(){
_initDriveUtility(){
switch(this._settings.get_string('drive-utility')){
case 'hddtemp':
this._utils.disks = new HddtempUtil.HddtempUtil();
break;
case 'udisks2':
this._utils.disks = new UDisks2.UDisks2(Lang.bind(this, function() {
this._utils.disks = new UDisks2.UDisks2(() => {
// this._updateDisplay(); we cannot change actor in background thread #74
}));
});
break;
case 'smartctl':
this._utils.disks = new smartctlUtil.smartctlUtil();
break;
}
},
}
_destroyDriveUtility : function(){
_destroyDriveUtility(){
if(this._utils.disks){
this._utils.disks.destroy();
delete this._utils.disks;
}
},
}
_initGpuUtility : function(){
_initGpuUtility(){
switch(this._settings.get_string('gpu-utility')){
case 'nvidia-settings':
this._utils.gpu = new NvidiaUtil.NvidiaUtil();
@@ -223,39 +220,39 @@ var FreonMenuButton = new Lang.Class({
this._utils.gpu = new BumblebeeNvidiaUtil.BumblebeeNvidiaUtil();
break;
}
},
}
_destroyGpuUtility : function(){
_destroyGpuUtility(){
if(this._utils.gpu){
this._utils.gpu.destroy();
delete this._utils.gpu;
}
},
}
_gpuUtilityChanged : function(){
_gpuUtilityChanged(){
this._destroyGpuUtility();
this._initGpuUtility();
this._querySensors();
},
}
_updateTimeChanged : function(){
_updateTimeChanged(){
Mainloop.source_remove(this._timeoutId);
this._addTimer();
},
}
_addTimer : function(){
this._timeoutId = Mainloop.timeout_add_seconds(this._settings.get_int('update-time'), Lang.bind(this, function (){
_addTimer(){
this._timeoutId = Mainloop.timeout_add_seconds(this._settings.get_int('update-time'), () => {
this._querySensors();
// readd to update queue
return true;
}));
},
});
}
_addSettingChangedSignal : function(key, callback){
_addSettingChangedSignal(key, callback){
this._settingChangedSignals.push(this._settings.connect('changed::' + key, callback));
},
}
_onDestroy: function(){
_onDestroy(){
this._destroyDriveUtility();
this._destroyGpuUtility();
Mainloop.source_remove(this._timeoutId);
@@ -264,19 +261,19 @@ var FreonMenuButton = new Lang.Class({
for (let signal of this._settingChangedSignals){
this._settings.disconnect(signal);
};
},
}
_querySensors: function(){
_querySensors(){
for (let sensor of Object.values(this._utils)) {
if (sensor.available) {
sensor.execute(Lang.bind(this,function(){
sensor.execute(() => {
// we cannot change actor in background thread #74
}));
});
}
}
},
}
_updateUI: function(){
_updateUI(){
let needUpdate = false;
for (let sensor of Object.values(this._utils)) {
if (sensor.available && sensor.updated) {
@@ -289,9 +286,9 @@ var FreonMenuButton = new Lang.Class({
this._updateDisplay(); // #74
this.debug('update display');
}
},
}
_fixNames: function(sensors){
_fixNames(sensors){
let names = [];
for (let s of sensors){
if(s.type == 'separator' ||
@@ -310,9 +307,9 @@ var FreonMenuButton = new Lang.Class({
}
names.push(name);
}
},
}
_updateDisplay: function(){
_updateDisplay(){
let gpuTempInfo = this._utils.sensors.gpu;
if (this._utils.gpu && this._utils.gpu.available)
@@ -468,9 +465,9 @@ var FreonMenuButton = new Lang.Class({
this.menu.addMenuItem(item);
this._appendStaticMenuItems();
}
},
}
_appendStaticMenuItems : function(){
_appendStaticMenuItems(){
// separator
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
@@ -487,9 +484,9 @@ var FreonMenuButton = new Lang.Class({
Util.spawn(["gnome-shell-extension-prefs", Me.metadata.uuid]);
});
this.menu.addMenuItem(settings);
},
}
_appendMenuItems : function(sensors){
_appendMenuItems(sensors){
this._lastSensorsCount = sensors.length;
this._sensorMenuItems = {};
let needGroupTemperature = this._settings.get_boolean('group-temperature');
@@ -518,7 +515,7 @@ var FreonMenuButton = new Lang.Class({
} else {
let key = s.key || s.label;
let item = new FreonItem.FreonItem(this._sensorIcons[s.type], key, s.label, s.value, s.displayName || undefined);
item.connect('activate', Lang.bind(this, function (self) {
item.connect('activate', (self) => {
let l = this._hotLabels[self.key];
let hotSensors = this._settings.get_strv('hot-sensors');
if(l){
@@ -563,7 +560,7 @@ var FreonMenuButton = new Lang.Class({
function(item, pos) {
return hotSensors.indexOf(item) == pos;
}));
}));
});
if (this._hotLabels[key]) {
item.main = true;
if(this._hotIcons[key])
@@ -598,14 +595,14 @@ var FreonMenuButton = new Lang.Class({
}
}
this._appendStaticMenuItems();
},
}
_toFahrenheit: function(c){
_toFahrenheit(c){
return ((9/5)*c+32);
},
}
_formatTemp: function(value) {
_formatTemp(value) {
if(value === null)
return 'N/A';
if (this._settings.get_string('unit')=='fahrenheit'){
@@ -617,12 +614,12 @@ var FreonMenuButton = new Lang.Class({
}
format += '%s';
return format.format(value, (this._settings.get_string('unit')=='fahrenheit') ? "\u00b0F" : "\u00b0C");
},
}
get positionInPanel(){
return this._settings.get_string('position-in-panel');
}
});
};
let freonMenu;

View File

@@ -1,13 +1,10 @@
const Lang = imports.lang;
const St = imports.gi.St;
const PopupMenu = imports.ui.popupMenu;
var FreonItem = new Lang.Class({
Name: 'FreonItem',
Extends: PopupMenu.PopupBaseMenuItem,
var FreonItem = class extends PopupMenu.PopupBaseMenuItem {
_init: function(gIcon, key, label, value, displayName) {
this.parent();
constructor(gIcon, key, label, value, displayName) {
super();
this._main = false;
this._key = key;
this._gIcon = gIcon;
@@ -17,7 +14,7 @@ var FreonItem = new Lang.Class({
this.actor.add(this._labelActor, {x_fill: true, expand: true});
this._valueLabel = new St.Label({text: value});
this.actor.add(this._valueLabel);
},
}
set main(main) {
if(main)
@@ -25,25 +22,25 @@ var FreonItem = new Lang.Class({
else
this.setOrnament(PopupMenu.Ornament.NONE);
this._main = main;
},
}
get main() {
return this._main;
},
}
get key() {
return this._key;
},
}
set display_name(text) {
return this._labelActor.text = text;
},
}
get gicon() {
return this._gIcon;
},
}
set value(value) {
this._valueLabel.text = value;
}
});
};

View File

@@ -1,15 +1,12 @@
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var HddtempUtil = new Lang.Class({
Name: 'HddtempUtil',
Extends: CommandLineUtil.CommandLineUtil,
var HddtempUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
this.parent();
constructor() {
super();
let hddtempArgv = GLib.find_program_in_path('hddtemp');
if(hddtempArgv) {
// check if this user can run hddtemp directly.
@@ -52,7 +49,7 @@ var HddtempUtil = new Lang.Class({
// use net cat to get data
this._argv = [nc, 'localhost', port.toString()];
}
},
}
get temp() {
if(!this._output)
@@ -78,4 +75,4 @@ var HddtempUtil = new Lang.Class({
return sensors;
}
});
};

View File

@@ -1,5 +1,5 @@
{
"shell-version": ["3.30"],
"shell-version": ["3.32"],
"uuid": "freon@UshakovVasilii_Github.yahoo.com",
"name": "Freon",
"description": "Shows CPU temperature, disk temperature, video card temperature (NVIDIA/Catalyst/Bumblebee&NVIDIA), voltage and fan RPM (forked from xtranophilist/gnome-shell-extension-sensors)",

View File

@@ -1,16 +1,13 @@
const ByteArray = imports.byteArray;
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var NvidiaUtil = new Lang.Class({
Name: 'NvidiaUtil',
Extends: CommandLineUtil.CommandLineUtil,
var NvidiaUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
constructor() {
this.parent();
let path = GLib.find_program_in_path('nvidia-settings');
this._argv = path ? [path, '-q', 'gpucoretemp', '-t'] : null;
@@ -29,7 +26,7 @@ var NvidiaUtil = new Lang.Class({
GLib.close(stdinFd);
GLib.close(stderrFd);
let childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, Lang.bind(this, function(pid, status, requestObj) {
let childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, (pid, status, requestObj) => {
let output = [];
let [line, size] = [null, 0];
@@ -42,9 +39,9 @@ var NvidiaUtil = new Lang.Class({
stdout.close(null);
GLib.source_remove(childWatch);
}));
});
}
},
}
get temp() {
if(!this._output)
@@ -79,4 +76,4 @@ var NvidiaUtil = new Lang.Class({
return gpus;
}
});
};

View File

@@ -1,10 +1,10 @@
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Lang = imports.lang;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
const _ = Gettext.gettext;
@@ -14,19 +14,16 @@ const modelColumn = {
}
function init() {
Convenience.initTranslations();
ExtensionUtils.initTranslations();
}
var FreonPrefsWidget = new GObject.Class({
Name: 'Freon.Prefs.Widget',
GTypeName: 'FreonPrefsWidget',
Extends: Gtk.Grid,
var FreonPrefsWidget = new GObject.registerClass(class Freon_FreonPrefsWidget extends Gtk.Grid {
_init: function(params) {
this.parent(params);
_init() {
super._init();
this.margin = this.row_spacing = this.column_spacing = 20;
this._settings = Convenience.getSettings();
this._settings = ExtensionUtils.getSettings();
let i = 0;
@@ -83,9 +80,9 @@ var FreonPrefsWidget = new GObject.Class({
key: 'gpu-utility', y : i, x : 2,
label: _('Video Card Temperature Utility')
});
},
}
_addSwitch : function(params){
_addSwitch(params){
let lbl = new Gtk.Label({label: params.label,halign : Gtk.Align.END});
this.attach(lbl, params.x, params.y, 1, 1);
let sw = new Gtk.Switch({halign : Gtk.Align.END, valign : Gtk.Align.CENTER});
@@ -95,9 +92,9 @@ var FreonPrefsWidget = new GObject.Class({
sw.set_tooltip_text(params.help);
}
this._settings.bind(params.key, sw, 'active', Gio.SettingsBindFlags.DEFAULT);
},
}
_addComboBox : function(params){
_addComboBox(params){
let model = new Gtk.ListStore();
model.set_column_types([GObject.TYPE_STRING, GObject.TYPE_STRING]);
@@ -112,12 +109,12 @@ var FreonPrefsWidget = new GObject.Class({
combobox.set_active(Object.keys(params.items).indexOf(this._settings.get_string(params.key)));
combobox.connect('changed', Lang.bind(this, function(entry) {
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))
}));
});
this.attach(new Gtk.Label({ label: params.label, halign : Gtk.Align.END}), params.x, params.y, 1, 1);
this.attach(combobox, params.x + 1, params.y, 1, 1);

View File

@@ -1,45 +1,42 @@
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var SensorsUtil = new Lang.Class({
Name: 'SensorsUtil',
Extends: CommandLineUtil.CommandLineUtil,
var SensorsUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
this.parent();
constructor() {
super();
let path = GLib.find_program_in_path('sensors');
// -A: Do not show adapter -j: JSON output
this._argv = path ? [path, '-A', '-j'] : null;
},
}
get temp() {
return this._parseGenericSensorsOutput(/^temp\d+_input/, 'temp');
},
}
get gpu() {
return this._parseGpuSensorsOutput(/^temp\d+_input/, 'temp');
},
}
get rpm() {
return this._parseGenericSensorsOutput(/^fan\d+_input/, 'rpm');
},
}
get volt() {
return this._parseGenericSensorsOutput(/^in\d+_input/, 'volt');
},
}
_parseGenericSensorsOutput: function(sensorFilter, sensorType) {
_parseGenericSensorsOutput(sensorFilter, sensorType) {
return this._parseSensorsOutput(sensorFilter, sensorType, false);
},
}
_parseGpuSensorsOutput: function(sensorFilter, sensorType) {
_parseGpuSensorsOutput(sensorFilter, sensorType) {
return this._parseSensorsOutput(sensorFilter, sensorType, true);
},
}
_parseSensorsOutput: function(sensorFilter, sensorType, gpuFlag) {
_parseSensorsOutput(sensorFilter, sensorType, gpuFlag) {
if(!this._output)
return [];
@@ -80,4 +77,4 @@ var SensorsUtil = new Lang.Class({
}
return sensors;
}
});
};

View File

@@ -1,18 +1,15 @@
const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var smartctlUtil = new Lang.Class({
Name: 'smartctlUtil',
Extends: CommandLineUtil.CommandLineUtil,
var smartctlUtil = class extends CommandLineUtil.CommandLineUtil {
_init: function() {
constructor() {
this.parent();
let path = GLib.find_program_in_path('smartctl');
this._argv = path ? [path, '-x', '/dev/nvme0'] : null;
},
}
get temp() {
if(!this._output)
@@ -42,11 +39,11 @@ var smartctlUtil = new Lang.Class({
}
return sensors;
},
}
get available(){
return true;
},
}
});
};

View File

@@ -1,4 +1,3 @@
const Lang = imports.lang;
const Gio = imports.gi.Gio;
const UDisksDriveProxy = Gio.DBusProxy.makeProxyWrapper(
@@ -18,7 +17,7 @@ const UDisksDriveAtaProxy = Gio.DBusProxy.makeProxyWrapper(
// Poor man's async.js
const Async = {
// mapping will be done in parallel
map: function(arr, mapClb /* function(in, successClb)) */, resClb /* function(result) */) {
map(arr, mapClb /* function(in, successClb)) */, resClb /* function(result) */) {
let counter = arr.length;
let result = [];
for (let i = 0; i < arr.length; ++i) {
@@ -31,30 +30,29 @@ const Async = {
}
// routines for handling of udisks2
var UDisks2 = new Lang.Class({
Name: 'UDisks2',
var UDisks2 = class {
_init: function(callback) {
constructor(callback) {
this.parent();
this._udisksProxies = [];
this._get_drive_ata_proxies(Lang.bind(this, function(proxies) {
this._get_drive_ata_proxies((proxies) => {
this._udisksProxies = proxies;
callback();
}));
});
this._updated = true;
},
}
get available(){
return this._udisksProxies.length > 0;
},
}
get updated (){
return this._updated;
},
}
set updated (updated){
this._updated = updated;
},
}
// creates a list of sensor objects from the list of proxies given
get temp() {
@@ -67,10 +65,10 @@ var UDisks2 = new Lang.Class({
temp: proxy.ata.SmartTemperature - 273.15
};
});
},
}
// calls callback with [{ drive: UDisksDriveProxy, ata: UDisksDriveAtaProxy }, ... ] for every drive that implements both interfaces
_get_drive_ata_proxies: function(callback) {
_get_drive_ata_proxies(callback) {
Gio.DBusObjectManagerClient.new(Gio.DBus.system, 0, "org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", null, null, function(src, res) {
try {
let objMgr = Gio.DBusObjectManagerClient.new_finish(res); //might throw
@@ -107,9 +105,9 @@ var UDisks2 = new Lang.Class({
global.log('[FREON] Could not find UDisks2 objects: ' + e);
}
});
},
}
destroy: function(callback) {
destroy(callback) {
for (let proxy of this._udisksProxies){
if(proxy.drive){
proxy.drive.run_dispose();
@@ -119,10 +117,10 @@ var UDisks2 = new Lang.Class({
}
}
this._udisksProxies = [];
},
}
execute: function(callback) {
execute(callback) {
this._updated = true;
},
}
});
};