Add NVIDIA card label detection

This commit is contained in:
UshakovVasilii
2014-07-05 02:45:00 +04:00
parent ffd153cc01
commit 3024c636ef

View File

@@ -11,6 +11,17 @@ const NvidiaUtil = new Lang.Class({
detect: function(){
let path = GLib.find_program_in_path('nvidia-settings');
this._argv = path ? [path, '-q', 'gpucoretemp', '-t'] : null;
this._label = 'NVIDIA';
if(this._argv){
// [0] ushakov-pc:0[gpu:0] (GeForce GTX 770)
for each(let line in GLib.spawn_command_line_sync(path + " -q gpus")){
let match = /.*\[gpu:[\d]\].*\(([\w\d\ ]+)\).*/.exec(line);
if(match){
this._label = match[1];
break;
}
}
}
return this._argv != null;
},
@@ -20,7 +31,7 @@ const NvidiaUtil = new Lang.Class({
for each(let line in this._output) {
if(!line)
continue;
return [{label: 'Nvidia', temp: parseFloat(line)}];
return [{label: this._label, temp: parseFloat(line)}];
}
return [];