Skip to content

Commit

Permalink
Merge pull request #15 from smcv/shell42
Browse files Browse the repository at this point in the history
Fix ByteArray warning, declare compatibility with GNOME Shell 42
  • Loading branch information
biji authored Apr 2, 2022
2 parents 46e7a9f + 74c0406 commit f343832
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ let mode;
let layoutManager;
let ioSpeedStaticIcon;
let ioSpeedIcon;
let byteArrayToString;

if (global.TextDecoder) {
// available in gjs >= 1.70 (GNOME Shell >= 42)
byteArrayToString = (new TextDecoder().decode);
}
else {
// gjs-specific
byteArrayToString = imports.byteArray.toString;
}

function init() {
cur = 0;
Expand All @@ -48,8 +58,8 @@ function parseStat(forceDot = false) {

let count = 0;
let line;
while ((line = dstream.read_line(null))) {
line = String(line);
while (([line, len] = dstream.read_line(null)) != null && line != null) {
line = byteArrayToString(line);
let fields = line.split(/ +/);
if (fields.length<=2) break;

Expand Down
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"3.36",
"3.38",
"40",
"41"
"41",
"42"
],
"url": "https://github.com/biji/harddiskled",
"uuid": "[email protected]",
Expand Down

0 comments on commit f343832

Please sign in to comment.