Add AMD video card temperature (aticonfig from Catalyst)

This commit is contained in:
UshakovVasilii
2014-06-23 22:16:05 +04:00
parent 80b08a9a17
commit 0e43f30351
7 changed files with 76 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
gnome-shell-extension-freon
====================================
Freon is forked from [gnome-shell-extension-sensors](https://github.com/xtranophilist/gnome-shell-extension-sensors). Freon is an extension for displaying CPU temperature, hard disk temperature, voltage and CPU fan RPM in GNOME Shell.
Freon is forked from [gnome-shell-extension-sensors](https://github.com/xtranophilist/gnome-shell-extension-sensors). Freon is an extension for displaying CPU temperature, HDD/SSD temperature, AMD video card temperature (Catalyst), voltage and CPU fan RPM in GNOME Shell.
More info in [wiki](https://github.com/UshakovVasilii/gnome-shell-extension-freon/wiki)

View File

@@ -68,6 +68,7 @@ const FreonMenuButton = new Lang.Class({
this._sensorsOutput = '';
this._hddtempOutput = '';
this._aticonfigOutput = '';
this._sensorIcons = {
temperature : Gio.icon_new_for_string(Me.path + '/icons/sensors-temperature-symbolic.svg'),
@@ -80,12 +81,15 @@ const FreonMenuButton = new Lang.Class({
this.actor.add_actor(this.statusLabel);
this.sensorsArgv = Utilities.detectSensors();
this.hddtempArgv = Utilities.detectHDDTemp();
if(settings.get_boolean('show-hdd-temp'))
this.hddtempArgv = Utilities.detectHDDTemp();
if(settings.get_boolean('show-aticonfig-temp'))
this.aticonfigArgv = Utilities.detectAtiConfig();
this.udisksProxies = [];
Utilities.UDisks.get_drive_ata_proxies(Lang.bind(this, function(proxies) {
this.udisksProxies = proxies;
this._updateDisplay(this._sensorsOutput, this._hddtempOutput);
this._updateDisplay(this._sensorsOutput, this._hddtempOutput, this._aticonfigOutput);
}));
this._settingChangedSignals = [];
@@ -94,9 +98,10 @@ const FreonMenuButton = new Lang.Class({
this._addSettingChangedSignal('show-label', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('main-sensor', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-decimal-value', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-hdd-temp', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-hdd-temp', Lang.bind(this, this._showHddTempChanged));
this._addSettingChangedSignal('show-fan-rpm', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-voltage', Lang.bind(this, this._querySensors));
this._addSettingChangedSignal('show-aticonfig-temp', Lang.bind(this, this._showAtiConfigChanged));
this.connect('destroy', Lang.bind(this, this._onDestroy));
@@ -113,6 +118,16 @@ const FreonMenuButton = new Lang.Class({
this._addTimer();
},
_showHddTempChanged : function(){
this.hddtempArgv = settings.get_boolean('show-hdd-temp') ? Utilities.detectHDDTemp() : undefined;
this._querySensors();
},
_showAtiConfigChanged : function(){
this.aticonfigArgv = settings.get_boolean('show-aticonfig-temp') ? Utilities.detectAtiConfig() : undefined;
this._querySensors();
},
_addTimer : function(){
this._timeoutId = Mainloop.timeout_add_seconds(settings.get_int('update-time'), Lang.bind(this, function (){
this._querySensors();
@@ -143,28 +158,30 @@ const FreonMenuButton = new Lang.Class({
},
_querySensors: function(){
//global.log('[FREON] Query sensors ' + (new Date()).getTime());
if (this.sensorsArgv){
this._sensorsFuture = new Utilities.Future(this.sensorsArgv, Lang.bind(this,function(stdout){
//global.log('START ' + (new Date()).getTime());
new Utilities.Future(this.sensorsArgv, Lang.bind(this,function(stdout){
this._sensorsOutput = stdout;
this._updateDisplay(this._sensorsOutput, this._hddtempOutput);
this._sensorsFuture = undefined;
//global.log('END__ ' + (new Date()).getTime());
this._updateDisplay(this._sensorsOutput, this._hddtempOutput, this._aticonfigOutput);
}));
}
if (settings.get_boolean('show-hdd-temp') && this.hddtempArgv){
this._hddtempFuture = new Utilities.Future(this.hddtempArgv, Lang.bind(this,function(stdout){
new Utilities.Future(this.hddtempArgv, Lang.bind(this,function(stdout){
this._hddtempOutput = stdout;
this._updateDisplay(this._sensorsOutput, this._hddtempOutput);
this._hddtempFuture = undefined;
this._updateDisplay(this._sensorsOutput, this._hddtempOutput, this._aticonfigOutput);
}));
}
if (settings.get_boolean('show-aticonfig-temp') && this.aticonfigArgv){
new Utilities.Future(this.aticonfigArgv, Lang.bind(this,function(stdout){
this._aticonfigOutput = stdout;
this._updateDisplay(this._sensorsOutput, this._hddtempOutput, this._aticonfigOutput);
}));
}
},
_updateDisplay: function(sensors_output, hddtemp_output){
_updateDisplay: function(sensors_output, hddtemp_output, aticonfig_output){
let tempInfo = [];
let fanInfo = [];
let voltageInfo = [];
@@ -182,6 +199,9 @@ const FreonMenuButton = new Lang.Class({
if(settings.get_boolean('show-hdd-temp') && this.hddtempArgv)
tempInfo = tempInfo.concat(Utilities.parseHddTempOutput(hddtemp_output, !(/nc$/.exec(this.hddtempArgv[0])) ? ': ' : '|'));
if(settings.get_boolean('show-aticonfig-temp') && this.aticonfigArgv)
tempInfo = tempInfo.concat(Utilities.parseAtiConfigOutput(aticonfig_output));
tempInfo = tempInfo.concat(Utilities.UDisks.create_list_from_proxies(this.udisksProxies));
tempInfo.sort(function(a,b) { return a['label'].localeCompare(b['label']) });

View File

@@ -2,7 +2,7 @@
"shell-version": ["3.12"],
"uuid": "freon@UshakovVasilii_Github.yahoo.com",
"name": "Freon",
"description": "Shows CPU temperature, HDD temperature, voltage and fan RPM (forked from xtranophilist/gnome-shell-extension-sensors)",
"description": "Shows CPU temperature, HDD/SSD temperature, AMD video card temperature (Catalyst), voltage and fan RPM (forked from xtranophilist/gnome-shell-extension-sensors)",
"settings-schema": "org.gnome.shell.extensions.freon",
"gettext-domain": "freon",
"url": "https://github.com/UshakovVasilii/gnome-shell-extension-freon"

View File

@@ -80,6 +80,10 @@ const FreonPrefsWidget = new GObject.Class({
this._addSwitch({key : 'show-voltage', y : i, x : 0,
label : _('Show Power Supply Voltage')});
this._addSwitch({key : 'show-aticonfig-temp', y : i, x : 2,
label : _('Use Catalyst'),
help : _('Show AMD video card temperature, use aticonfig from Catalyst driver.')});
},
_addSwitch : function(params){

View File

@@ -51,5 +51,11 @@
<description>Display voltage of various components.</description>
</key>
<key type="b" name="show-aticonfig-temp">
<default>false</default>
<summary>Show AMD Card Temperature (Catalyst)</summary>
<description>Show AMD card temperature, use aticonfig from Catalyst driver.</description>
</key>
</schema>
</schemalist>

View File

@@ -75,6 +75,11 @@ function detectHDDTemp() {
return undefined;
}
function detectAtiConfig() {
let path = GLib.find_program_in_path('aticonfig');
return path ? [path, '--odgt'] : undefined;
}
function parseSensorsOutput(txt,parser) {
let sensors_output = txt.split("\n");
let feature_label = undefined;
@@ -184,6 +189,32 @@ function parseHddTempOutput(txt, sep) {
return sensors;
}
/*
Default Adapter - AMD Radeon R9 200 Series
Sensor 0: Temperature - 37.00 C
*/
function parseAtiConfigOutput(txt) {
if(!txt)
return [];
let output = txt.split('\n');
let label = null;
let temp = null;
for each(let line in 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}];
}
function filterTemperature(tempInfo) {
return tempInfo['temp'] > 0 && tempInfo['temp'] < 115;
}