Skip to content

Commit

Permalink
add backward support for Gnome 3.28 , fix NaN temperature and disk IO…
Browse files Browse the repository at this point in the history
… on Ubuntu 18.04

add backward support for Gnome 3.28 , fix NaN temperature and disk IO on Ubuntu 18.04 . 

related issues: paradoxxxzero#520 paradoxxxzero#526 paradoxxxzero#594 paradoxxxzero#597 paradoxxxzero#601  thankjura/ds4battery#4  
I don't have dedicated GPU to test paradoxxxzero#592 but it should be possible to fix in the same way.

inspired by @shemgp and @EBoisseauSierra
  • Loading branch information
bluet committed Apr 6, 2021
1 parent 0dfdaa9 commit 96ba6ad
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions system-monitor@paradoxxx.zero.gmail.com/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ Clutter.Actor.prototype.reparent = function reparent(newParent) {
newParent.add_child(this);
}

function parse_bytearray(bytearray) {
if (!ByteArray.toString(bytearray).match(/GjsModule byteArray/)) {
return ByteArray.toString(bytearray);
}
return bytearray
}

function l_limit(t) {
return (t > 0) ? t : 1000;
}
Expand Down Expand Up @@ -1437,7 +1444,7 @@ const Disk = class SystemMonitor_Disk extends ElementBase {
let file = Gio.file_new_for_path('/proc/diskstats');
file.load_contents_async(null, (source, result) => {
let as_r = source.load_contents_finish(result);
let lines = ByteArray.toString(as_r[1]).split('\n');
let lines = parse_bytearray(as_r[1]).toString().split('\n');

for (let i = 0; i < lines.length; i++) {
let line = lines[i];
Expand Down Expand Up @@ -2019,7 +2026,7 @@ const Thermal = class SystemMonitor_Thermal extends ElementBase {
let file = Gio.file_new_for_path(sfile);
file.load_contents_async(null, (source, result) => {
let as_r = source.load_contents_finish(result)
this.temperature = Math.round(parseInt(ByteArray.toString(as_r[1])) / 1000);
this.temperature = Math.round(parseInt(parse_bytearray(as_r[1])) / 1000);
if (this.fahrenheit_unit) {
this.temperature = Math.round(this.temperature * 1.8 + 32);
}
Expand Down Expand Up @@ -2090,7 +2097,7 @@ const Fan = class SystemMonitor_Fan extends ElementBase {
let file = Gio.file_new_for_path(sfile);
file.load_contents_async(null, (source, result) => {
let as_r = source.load_contents_finish(result)
this.rpm = parseInt(ByteArray.toString(as_r[1]));
this.rpm = parseInt(parse_bytearray(as_r[1]));
});
} else if (this.display_error) {
global.logError('error reading: ' + sfile);
Expand Down

0 comments on commit 96ba6ad

Please sign in to comment.