Files
gnome-shell-extension-freon/freon@UshakovVasilii_Github.yahoo.com/aticonfigUtil.js
2019-03-20 10:28:11 +03:00

40 lines
1.1 KiB
JavaScript

const GLib = imports.gi.GLib;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const CommandLineUtil = Me.imports.commandLineUtil;
var AticonfigUtil = class extends CommandLineUtil.CommandLineUtil {
constructor() {
super();
let path = GLib.find_program_in_path('aticonfig');
this._argv = path ? [path, '--odgt'] : null;
}
/*
Default Adapter - AMD Radeon R9 200 Series
Sensor 0: Temperature - 37.00 C
*/
get temp() {
if(!this._output)
return [];
let label = null;
let temp = null;
for (let line of this._output) {
if(!line)
continue;
let r;
if(line.indexOf('Adapter') > 0)
label = (r = /Adapter \- (.*)/.exec(line)) ? r[1] : undefined;
if(line.indexOf('Temperature') > 0)
temp = (r = /Temperature \- (\d{1,3}.\d{1,2})/.exec(line)) ? parseFloat(r[1]) : undefined;
}
if(!label || !temp)
return [];
return [{ label : label.trim(), temp : temp}];
}
};