upgrade 1

This commit is contained in:
2025-12-07 09:31:52 +01:00
parent f7b56975cb
commit 491ff95cfd
4 changed files with 37 additions and 21 deletions

View File

@@ -24,9 +24,12 @@ export default class CMUDExtension extends Extension {
area_mem.connect('repaint', this.onRepaint_mem);
box.add_child(area_mem);
var label = new St.Label({ text: '↑ 0KB/s\n↓ 0KB/s', y_align: Clutter.ActorAlign.CENTER });
label.set_style('text-align:center; font-family:Noto Mono');
box.add_child(label);
var label = new St.Label({
text: 'CPU 0%\nMEM 0%',
y_align: Clutter.ActorAlign.CENTER,
});
label.set_style('text-align:center; font-family:Noto Mono');
box.add_child(label);
var area_cpu = new St.DrawingArea();
area_cpu.width = 3;
@@ -62,19 +65,32 @@ export default class CMUDExtension extends Extension {
this.label_tooltip.hide();
});
this._timeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
var net = this.net();
label.set_text('↑' + this.B2G(net.ubs) + '/s\n↓' + this.B2G(net.dbs) + '/s');
this.mem();
area_mem.queue_repaint();
this.cpu();
area_cpu.queue_repaint();
var s = 'UPT: ' + this.uptime() + '\nCPU: ' + cp + '%\nMEM: ' + this.mem() + '\nUPB: ' + this.B2G(net.ub) + '\nDNB: ' + this.B2G(net.db);
//menuItem.label.text = s;
this.label_tooltip.text = s;
// Run as loop, not once.
return GLib.SOURCE_CONTINUE;
});
this._timeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {
// Met à jour mémoire et CPU
this.mem(); // met à jour la variable globale mp (% mémoire)
area_mem.queue_repaint();
this.cpu(); // met à jour la variable globale cp (% CPU)
area_cpu.queue_repaint();
// Affiche CPU / MEM dans la barre
label.set_text(`CPU ${cp}%\nMEM ${mp}%`);
// On garde les infos réseau pour le tooltip
const net = this.net(); // { db, ub, dbs, ubs }
const s =
'UPT: ' + this.uptime() +
'\nCPU: ' + cp + '%' +
'\nMEM: ' + mp + '%' +
'\nUPB: ' + this.B2G(net.ub) +
'\nDNB: ' + this.B2G(net.db);
this.label_tooltip.text = s;
return GLib.SOURCE_CONTINUE;
});
}

View File

@@ -1,6 +1,6 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"author": "sonichy",
"author": "gile.soulier",
"description": "Display uptime, cpu, memory, upload, download on GNOME taskbar.",
"name": "CMUD",
"shell-version": [
@@ -9,7 +9,7 @@
"47",
"48"
],
"url": "https://github.com/sonichy/GNOME_extension",
"uuid": "CMUD@sonichy",
"version": 7
}
"url": "https://gitea.maison43.duckdns.org/gilles/GNOME_extension",
"uuid": "CMUD@gil.soulier",
"version": 8
}

View File

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 135 KiB