Skip to content

Commit

Permalink
TextDecoder().decode
Browse files Browse the repository at this point in the history
  • Loading branch information
biji committed Nov 24, 2023
1 parent ac82187 commit 13ea27f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,11 @@ export default class HardDiskLEDExtension extends Extension {
layoutManager = null;
ioSpeedStaticIcon = null;
ioSpeedIcon = null;
byteArrayToString = null;

init() {
this.cur = 0;
this.lastCount = 0;

if (global.TextDecoder) {
// available in gjs >= 1.70 (GNOME Shell >= 42)
this.byteArrayToString = (new TextDecoder().decode);
} else {
// gjs-specific, imports.byteArray is still available in (GNOME Shell 45 >=) but discouraged!
this.byteArrayToString = imports.byteArray.toString;
}
}

changeMode() {
Expand All @@ -51,7 +43,7 @@ export default class HardDiskLEDExtension extends Extension {
let input_file = Gio.file_new_for_path('/proc/diskstats');

let [, contents, _etag] = input_file.load_contents(null);
contents = this.byteArrayToString(contents);
contents = new TextDecoder().decode(contents);
let lines = contents.split('\n');

let count = 0;
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
],
"url": "https://github.com/biji/harddiskled",
"uuid": "[email protected]",
"version": 36
"version": 37
}

0 comments on commit 13ea27f

Please sign in to comment.