Skip to content

Commit bf49bcd

Browse files
authored
multicore-sys-monitor v3.4.0: Smoother reading of most system data (#8275)
* multicore-sys-monitor v3.4.0: Smoother reading of most system data * brightness-and-gamma-applet v3.0.2: Makes the Screen Temperature changes smoother
1 parent 098e0a2 commit bf49bcd

File tree

7 files changed

+105
-70
lines changed

7 files changed

+105
-70
lines changed

brightness-and-gamma-applet@cardsurf/files/brightness-and-gamma-applet@cardsurf/6.6/applet.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,11 +1208,10 @@ class BrightnessAndGamma extends Applet.IconApplet {
12081208
}
12091209

12101210
update_xsct() {
1211-
//~ global.log("Screen temp: " + this.screen_temp);
1212-
//~ global.log("Brightness: " + this.brightness);
12131211
let xsct_temp = this.screen_temp;
12141212
let xsct_brightness = Math.min(this.brightness / 100, 1.0);
1215-
Util.spawnCommandLine(`/usr/bin/env sh -c "xsct ${xsct_temp} ${xsct_brightness}"`);
1213+
//~ Util.spawnCommandLineAsync(`/usr/bin/env sh -c "xsct ${xsct_temp} ${xsct_brightness}"`);
1214+
Util.spawnCommandLineAsync(`xsct ${xsct_temp} ${xsct_brightness}`);
12161215
}
12171216

12181217
is_screen_output_valid(output_index) {

brightness-and-gamma-applet@cardsurf/files/brightness-and-gamma-applet@cardsurf/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v3.0.2~20260203
2+
* Asynchronously change of Screen Temperature.
3+
14
### v3.0.1~20260202
25
* Now can display shortcuts in the menu.
36
* Improves translation.

brightness-and-gamma-applet@cardsurf/files/brightness-and-gamma-applet@cardsurf/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"description": "Sets brightness and gamma levels of a screen",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"uuid": "brightness-and-gamma-applet@cardsurf",
55
"name": "Brightness and gamma applet",
66
"author": "claudiux"

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/6.4/applet.js

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const {
2121
} = imports.ui.extension; //Extension
2222

2323
const { to_string } = require("./lib/tostring");
24+
const { readFileAsync } = require("./lib/readFileAsync");
2425
const Graphs = require('./lib/Graphs');
2526
const {
2627
timeout_add,
@@ -484,26 +485,16 @@ class MCSM extends Applet.IconApplet {
484485
posConfigure = i;
485486
}
486487
}
487-
//~ global.log("posConfigure: " + posConfigure);
488488
if (posConfigure != -1) {
489489
menuChildren[posConfigure].destroy();
490-
//~ let context_menu_item_configure = new PopupMenu.PopupSubMenuMenuItem(_("Configure..."));
491490
this.context_menu_item_configure = new PopupMenu.PopupSubMenuMenuItem(_("Configure..."));
492-
//~ context_menu_item_configure.menu.addAction(_("General"), () => { this.configureApplet(0) });
493-
//~ context_menu_item_configure.menu.addAction(_("CPU"), () => { this.configureApplet(1) });
494-
//~ context_menu_item_configure.menu.addAction(_("Memory"), () => { this.configureApplet(2) });
495-
//~ context_menu_item_configure.menu.addAction(_("Network"), () => { this.configureApplet(3) });
496-
//~ context_menu_item_configure.menu.addAction(_("Disk IO"), () => { this.configureApplet(4) });
497-
//~ context_menu_item_configure.menu.addAction(_("Disk Usage"), () => { this.configureApplet(5) });
498-
//~ context_menu_item_configure.menu.addAction(_("Colors"), () => { this.configureApplet(6) });
499491
this.context_menu_item_configure.menu.addAction(_("General"), () => { this.configureApplet(0) });
500492
this.context_menu_item_configure.menu.addAction(_("CPU"), () => { this.configureApplet(1) });
501493
this.context_menu_item_configure.menu.addAction(_("Memory"), () => { this.configureApplet(2) });
502494
this.context_menu_item_configure.menu.addAction(_("Network"), () => { this.configureApplet(3) });
503495
this.context_menu_item_configure.menu.addAction(_("Disk IO"), () => { this.configureApplet(4) });
504496
this.context_menu_item_configure.menu.addAction(_("Disk Usage"), () => { this.configureApplet(5) });
505497
this.context_menu_item_configure.menu.addAction(_("Colors"), () => { this.configureApplet(6) });
506-
//~ this._applet_context_menu.addMenuItem(context_menu_item_configure, posConfigure);
507498
this._applet_context_menu.addMenuItem(this.context_menu_item_configure, posConfigure);
508499
}
509500
}
@@ -585,19 +576,21 @@ class MCSM extends Applet.IconApplet {
585576
}
586577
var ret = "";
587578
if (GLib.file_test(NETWORK_DEVICES_STATUS_PATH, GLib.FileTest.EXISTS)) {
588-
let [succes, status] = GLib.file_get_contents(NETWORK_DEVICES_STATUS_PATH);
589-
status = to_string(status).trim();
590-
ret += status;
579+
readFileAsync(NETWORK_DEVICES_STATUS_PATH).then((status) => {
580+
ret += status;
581+
});
591582
} else {
592583
const net_dir_path = "/sys/class/net";
593584
const net_dir = Gio.file_new_for_path(net_dir_path);
594585
const children = net_dir.enumerate_children("standard::name,standard::type", Gio.FileQueryInfoFlags.NONE, null);
595586
for (let child of children) {
596587
let name = child.get_name();
597588
let operstate_file_path = `${net_dir_path}/${name}/operstate`;
598-
let [net_success, net_status] = GLib.file_get_contents(operstate_file_path);
599-
net_status = to_string(net_status).trim();
600-
ret += `${name}:${net_status} `;
589+
590+
readFileAsync(operstate_file_path).then( (net_status) => {
591+
net_status = net_status.trim();
592+
ret += `${name}:${net_status} `;
593+
});
601594
}
602595
}
603596
var returnedDevices = ret.trim().split(" ");
@@ -756,10 +749,8 @@ class MCSM extends Applet.IconApplet {
756749
if (!this.Mem_enabled) return;
757750
let old, duration;
758751
if (DEBUG) old = Date.now();
759-
var contents = "";
760-
let [success, contents_array] = GLib.file_get_contents("/proc/meminfo");
761-
if (success) {
762-
contents = to_string(contents_array);
752+
753+
readFileAsync("/proc/meminfo").then((contents) => {
763754
var data = [];
764755
const lines = contents.split("\n");
765756
const p = 1024;
@@ -798,18 +789,16 @@ class MCSM extends Applet.IconApplet {
798789
duration = Date.now() - old;
799790
global.log(UUID + " - get_mem_info Duration: " + duration + " ms.");
800791
}
801-
}
792+
});
802793
}
803794

804795
get_cpu_info() {
805796
if (!this.isRunning) return;
806797
if (!this.CPU_enabled) return;
807798
let old, duration;
808799
if (DEBUG) old = Date.now();
809-
var contents = "";
810-
let [success, contents_array] = GLib.file_get_contents("/proc/stat");
811-
if (success) {
812-
contents = to_string(contents_array);
800+
801+
readFileAsync("/proc/stat").then((contents) => {
813802
var data = [];
814803
const lines = contents.split("\n");
815804
var ret = "";
@@ -883,11 +872,12 @@ class MCSM extends Applet.IconApplet {
883872
this.oldCPUvalues = values;
884873

885874
this.multiCpuProvider.setData(data);
886-
}
887-
if (DEBUG) {
888-
duration = Date.now() - old;
889-
global.log(UUID + " - get_cpu_info Duration: " + duration + " ms.");
890-
}
875+
876+
if (DEBUG) {
877+
duration = Date.now() - old;
878+
global.log(UUID + " - get_cpu_info Duration: " + duration + " ms.");
879+
}
880+
});
891881
}
892882

893883
get_net_info() {
@@ -999,44 +989,47 @@ class MCSM extends Applet.IconApplet {
999989
deviceGrans[d["id"]] = d["discGran"];
1000990
}
1001991
var data = [];
1002-
let diskstats = (to_string(GLib.file_get_contents("/proc/diskstats")[1])).trim().split("\n");
1003-
var sum_read = 0;
1004-
var sum_write = 0;
1005-
for (let line of diskstats) {
1006-
if (line.includes("loop")) continue;
1007-
line = line.trim();
1008-
line = line.replace(/\ +/g, " ");
1009-
let infos = line.split(" ");
1010-
let _dev = infos[2];
1011-
if (usedDevices.indexOf(_dev) < 0) continue;
1012-
let discGran = 1 * deviceGrans[_dev];
1013-
let [_read, _write] = [1 * infos[5] * discGran, 1 * infos[9] * discGran];
992+
readFileAsync("/proc/diskstats").then( (result) => {
993+
let diskstats = result.trim().split("\n");
994+
995+
var sum_read = 0;
996+
var sum_write = 0;
997+
for (let line of diskstats) {
998+
if (line.includes("loop")) continue;
999+
line = line.trim();
1000+
line = line.replace(/\ +/g, " ");
1001+
let infos = line.split(" ");
1002+
let _dev = infos[2];
1003+
if (usedDevices.indexOf(_dev) < 0) continue;
1004+
let discGran = 1 * deviceGrans[_dev];
1005+
let [_read, _write] = [1 * infos[5] * discGran, 1 * infos[9] * discGran];
1006+
if (this.Disk_mergeAll) {
1007+
sum_read = 1 * sum_read + _read;
1008+
sum_write = 1 * sum_write + _write;
1009+
} else {
1010+
data.push({
1011+
"id": _dev,
1012+
"name": deviceNames[_dev],
1013+
"read": _read,
1014+
"write": _write
1015+
});
1016+
}
1017+
1018+
}
10141019
if (this.Disk_mergeAll) {
1015-
sum_read = 1 * sum_read + _read;
1016-
sum_write = 1 * sum_write + _write;
1017-
} else {
10181020
data.push({
1019-
"id": _dev,
1020-
"name": deviceNames[_dev],
1021-
"read": _read,
1022-
"write": _write
1021+
"id": "Disks",
1022+
"name": _("Disks"),
1023+
"read": sum_read,
1024+
"write": sum_write
10231025
});
10241026
}
1025-
1026-
}
1027-
if (this.Disk_mergeAll) {
1028-
data.push({
1029-
"id": "Disks",
1030-
"name": _("Disks"),
1031-
"read": sum_read,
1032-
"write": sum_write
1033-
});
1034-
}
1035-
this.diskProvider.setData(data);
1036-
if (DEBUG) {
1037-
duration = Date.now() - old;
1038-
global.log(UUID + " - get_disk_info Duration: " + duration + " ms.");
1039-
}
1027+
this.diskProvider.setData(data);
1028+
if (DEBUG) {
1029+
duration = Date.now() - old;
1030+
global.log(UUID + " - get_disk_info Duration: " + duration + " ms.");
1031+
}
1032+
});
10401033
}
10411034

10421035
get_disk_usage() {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//!/usr/bin/cjs
2+
const Gio = imports.gi.Gio;
3+
const GLib = imports.gi.GLib;
4+
const ByteArray = imports.byteArray;
5+
6+
const readFileAsync = function(file, opts = {utf8: true}) {
7+
const {utf8} = opts;
8+
return new Promise(function(resolve, reject) {
9+
if (typeof file === 'string' || file instanceof String) {
10+
file = Gio.File.new_for_path(file);
11+
}
12+
if (!file.query_exists(null)) reject(new Error('File does not exist.'));
13+
file.load_contents_async(null, function(object, result) {
14+
try {
15+
let [success, data] = file.load_contents_finish(result);
16+
if (!success) return reject(new Error('File cannot be read.'));
17+
if (utf8) {
18+
if (data instanceof Uint8Array) data = ByteArray.toString(data);
19+
else data = data.toString();
20+
}
21+
resolve(data);
22+
} catch(e) {
23+
reject(e);
24+
}
25+
});
26+
});
27+
};
28+
29+
const readJSONAsync = function(file) {
30+
return readFileAsync(file).then(function(json) {
31+
return JSON.parse(json);
32+
});
33+
};
34+
35+
module.exports = { readFileAsync, readJSONAsync }

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### v3.4.0~20260203
2+
* Smoother reading of most system data.
3+
* Uses readFileAsync module.
4+
15
### v3.3.0~20260106
26
* Better takes into account HiDPI display.
37
* Changes graph height in pixels with % of panel height.

multicore-sys-monitor@ccadeptic23/files/multicore-sys-monitor@ccadeptic23/metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"uuid": "multicore-sys-monitor@ccadeptic23",
33
"name": "Multi-Core System Monitor",
4-
"version": "3.3.0",
4+
"version": "3.4.0",
55
"description": "Displays in realtime the cpu usage for each core/cpu and overall memory usage.",
66
"multiversion": true,
77
"cinnamon-version": [
@@ -22,7 +22,8 @@
2222
"5.6",
2323
"6.0",
2424
"6.2",
25-
"6.4"
25+
"6.4",
26+
"6.6"
2627
],
2728
"author": "claudiux"
2829
}

0 commit comments

Comments
 (0)