Merge pull request #120 from EUA/master

Addition of custom smartctl query for NVME devices.
This commit is contained in:
Vasilii
2019-01-06 19:30:54 +03:00
committed by GitHub
3 changed files with 57 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ const AticonfigUtil = Me.imports.aticonfigUtil;
const NvidiaUtil = Me.imports.nvidiaUtil;
const HddtempUtil = Me.imports.hddtempUtil;
const SensorsUtil = Me.imports.sensorsUtil;
const smartctlUtil = Me.imports.smartctlUtil;
const BumblebeeNvidiaUtil = Me.imports.bumblebeeNvidiaUtil;
const FreonItem = Me.imports.freonItem;
@@ -197,6 +198,9 @@ var FreonMenuButton = new Lang.Class({
// this._updateDisplay(); we cannot change actor in background thread #74
}));
break;
case 'smartctl':
this._utils.disks = new smartctlUtil.smartctlUtil();
break;
}
},

View File

@@ -69,7 +69,7 @@ var FreonPrefsWidget = new GObject.Class({
help : _("Works if you have more than three voltage sensors")});
this._addComboBox({
items : {none : 'None', hddtemp : 'Hddtemp', udisks2 : 'UDisks2'},
items : {none : 'None', hddtemp : 'Hddtemp', udisks2 : 'UDisks2', smartctl : 'smartctl'},
key: 'drive-utility', y : i, x : 0,
label: _('HDD/SSD Temperature Utility')
});

View File

@@ -0,0 +1,52 @@
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,
_init: function() {
this.parent();
let path = GLib.find_program_in_path('smartctl');
this._argv = path ? [path, '-x', '/dev/nvme0'] : null;
},
get temp() {
if(!this._output)
return [];
let smartctlOutput = [];
smartctlOutput = this._output;
let sensors = [];
let slabel="Temperature Sensor";
for (let line of smartctlOutput) {
let matchModel = /Model Number:/.exec( line.toString() );
if(matchModel){
let sline=line.split(/\s+/);
slabel=sline.slice(2).join(" ");
}
//let line = "Temperature Sensor 1: 37 Celsius"
let match = /Temperature Sensor \d: *\w\d Celsius/.exec( line.toString() );
//let match = /Use smartctl.*/.exec( line.toString() );
//let match = /.*\[Temperature Sensor \d: .*\d Celcius.*/.exec(line.toString());
if(match){
let sline=line.split(/\s+/);
let sensor = { label: slabel+" "+sline[2][0], temp: parseFloat(sline[3]) };
sensors.push(sensor);
}
}
return sensors;
},
get available(){
return true;
},
});