mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 00:14:14 +09:00
* Migrate Plugin to Gnome 45 Shell * Use TextDecoder instead of ByteArray or toString() * use the Glib timeout functions * remove unused imports
39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
import GLib from 'gi://GLib';
|
|
|
|
import CommandLineUtil from './commandLineUtil.js';
|
|
|
|
export default class AticonfigUtil extends 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}];
|
|
}
|
|
|
|
};
|