Skip to content

Commit

Permalink
compatibility for gnome 42.4
Browse files Browse the repository at this point in the history
  • Loading branch information
biji committed Sep 27, 2022
1 parent cf5e35c commit 779cf0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
18 changes: 10 additions & 8 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,20 @@ function changeMode() {
function parseStat(forceDot = false) {
try {
let input_file = Gio.file_new_for_path('/proc/diskstats');
let fstream = input_file.read(null);
let dstream = Gio.DataInputStream.new(fstream);

let [, contents, etag] = input_file.load_contents(null);
contents = byteArrayToString(contents);
let lines = contents.split('\n');

let count = 0;
let line;
while (([line, len] = dstream.read_line(null)) != null && line != null) {
line = byteArrayToString(line);

for (let i=0;i<lines.length;i++) {
line = lines[i];
let fields = line.split(/ +/);
if (fields.length<=2) break;

if (parseInt(fields[2])%16 === 0
if (parseInt(fields[2])%16 === 0
&& fields[3].indexOf('md0') != 0
&& fields[3].indexOf('ram0') != 0
&& fields[3].indexOf('dm-0') != 0
Expand All @@ -72,9 +75,8 @@ function parseStat(forceDot = false) {
count = count + parseInt(fields[6]) + parseInt(fields[10]);
// log(fields[3] + ':' + fields[6] + ' ' + fields[10] + ' ' + count);
}

}
fstream.close(null);

if (lastCount === 0) lastCount = count;

Expand Down Expand Up @@ -152,7 +154,7 @@ function speedToString(amount) {
digits = 0;
else if (amount >= 10) // 10MB 10.2
digits = 1;
else
else
digits = 2;
return String(amount.toFixed(digits)) + speed_map[unit];
}
Expand Down
14 changes: 7 additions & 7 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Show harddisk activity (IO speed read/write and LED). Click to change led size",
"name": "Harddisk LED",
"_generated": "Generated by SweetTooth, do not edit",
"description": "Show harddisk activity (IO speed read/write and LED). Click to change led size",
"name": "Harddisk LED",
"shell-version": [
"3.32",
"3.34",
Expand All @@ -11,8 +11,8 @@
"41",
"42",
"43"
],
"url": "https://github.com/biji/harddiskled",
"uuid": "[email protected]",
"version": 31
],
"url": "https://github.com/biji/harddiskled",
"uuid": "[email protected]",
"version": 32
}

0 comments on commit 779cf0c

Please sign in to comment.