Files
gnome-shell-extension-freon/freon@UshakovVasilii_Github.yahoo.com/nvidiaUtil.js
UshakovVasilii d5777b70d8 clean code
2015-04-11 01:01:16 +03:00

41 lines
1.1 KiB
JavaScript

const Lang = imports.lang;
const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
const NvidiaUtil = new Lang.Class({
Name: 'NvidiaUtil',
Extends: CommandLineUtil.CommandLineUtil,
_init: function() {
this.parent();
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;
}
}
}
},
get temp() {
if(!this._output)
return [];
for each(let line in this._output) {
if(!line)
continue;
return [{label: this._label, temp: parseFloat(line)}];
}
return [];
}
});