system-monitor-graph@rcassani: Reduce UI stutter (#1570)

* Different way to initialize subprocess to remove UI freeze

* Update translations: `.pot` and Spanish translation

* Resolves #1546
This commit is contained in:
Raymundo Cassani 2025-08-27 21:54:22 -04:00 committed by GitHub
parent d50c250a1d
commit 628d16d6a5
13 changed files with 135 additions and 42 deletions

View File

@ -827,49 +827,94 @@ SystemMonitorGraph.prototype = {
},
get_nvidia_gpu_use: function() {
let subprocess
try {
subprocess = Gio.Subprocess.new(
let [success, child_pid, std_in, std_out, std_err] = GLib.spawn_async_with_pipes(
null,
['/usr/bin/nvidia-smi', '--query-gpu=utilization.gpu', '--format=csv', '--id='+ this.gpu_id],
Gio.SubprocessFlags.STDOUT_PIPE|Gio.SubprocessFlags.STDERR_PIPE
null,
GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN,
null
);
} catch (err) {
GLib.close(std_in);
GLib.close(std_err);
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, child_pid, function(pid, wait_status, user_data) {
GLib.spawn_close_pid(child_pid);
});
if(!success) {
throw new Error(_('Error executing nvidia-smi command.'));
}
let deskletInstance = this;
let ioChannelStdOut = GLib.IOChannel.unix_new(std_out);
let tagWatchStdOut = GLib.io_add_watch(
ioChannelStdOut, GLib.PRIORITY_DEFAULT,
GLib.IOCondition.IN | GLib.IOCondition.HUP,
function(channel, condition, data) {
if(condition != GLib.IOCondition.HUP) {
let [status, out] = channel.read_to_end();
let out_string = out.toString();
deskletInstance.gpu_use = parseInt(out_string.match(/[^\r\n]+/g)[1]); // parse integer in second line
}
GLib.source_remove(tagWatchStdOut);
channel.shutdown(true);
}
);
} catch(error) {
this.gpu_use = 0;
return;
}
subprocess.communicate_utf8_async(null, null, (subprocess, result) => {
let [, stdout, stderr] = subprocess.communicate_utf8_finish(result);
this.gpu_use = parseInt(stdout.match(/[^\r\n]+/g)[1]); // parse integer in second line
});
},
get_nvidia_gpu_mem: function() {
let subprocess
try {
subprocess = Gio.Subprocess.new(
let [success, child_pid, std_in, std_out, std_err] = GLib.spawn_async_with_pipes(
null,
['/usr/bin/nvidia-smi', '--query-gpu=memory.total,memory.used', '--format=csv', '--id='+ this.gpu_id],
Gio.SubprocessFlags.STDOUT_PIPE|Gio.SubprocessFlags.STDERR_PIPE
null,
GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN,
null
);
} catch {
GLib.close(std_in);
GLib.close(std_err);
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, child_pid, function(pid, wait_status, user_data) {
GLib.spawn_close_pid(child_pid);
});
if(!success) {
throw new Error(_('Error executing nvidia-smi command.'));
}
let deskletInstance = this;
let ioChannelStdOut = GLib.IOChannel.unix_new(std_out);
let tagWatchStdOut = GLib.io_add_watch(
ioChannelStdOut, GLib.PRIORITY_DEFAULT,
GLib.IOCondition.IN | GLib.IOCondition.HUP,
function(channel, condition, data) {
if(condition != GLib.IOCondition.HUP) {
let [status, out] = channel.read_to_end();
let out_string = out.toString();
let fslines = out_string.split(/\r?\n/); // Line0:Headers Line1:Values
let items = fslines[1].split(','); // Values are comma-separated
let mem_tot
let mem_usd
if (deskletInstance.data_prefix_gpumem == 1) {
// decimal prefix
mem_tot = parseInt(items[0]) * 1024 * 1024 / GB_TO_B;
mem_usd = parseInt(items[1]) * 1024 * 1024 / GB_TO_B;
} else {
// binary prefix
mem_tot = parseInt(items[0]) / GIB_TO_MIB;
mem_usd = parseInt(items[1]) / GIB_TO_MIB;
}
deskletInstance.gpu_mem[0] = mem_tot;
deskletInstance.gpu_mem[1] = mem_usd;
}
GLib.source_remove(tagWatchStdOut);
channel.shutdown(true);
}
);
} catch(error) {
this.gpu_mem[0] = 0;
this.gpu_mem[1] = 0;
return;
}
subprocess.communicate_utf8_async(null, null, (subprocess, result) => {
let [, stdout, stderr] = subprocess.communicate_utf8_finish(result);
let fslines = stdout.split(/\r?\n/); // Line0:Headers Line1:Values
let items = fslines[1].split(','); // Values are comma-separated
let mem_tot
let mem_usd
if (this.data_prefix_gpumem == 1) {
// decimal prefix
mem_tot = parseInt(items[0]) * 1024 * 1024 / GB_TO_B;
mem_usd = parseInt(items[1]) * 1024 * 1024 / GB_TO_B;
} else {
// binary prefix
mem_tot = parseInt(items[0]) / GIB_TO_MIB;
mem_usd = parseInt(items[1]) / GIB_TO_MIB;
}
this.gpu_mem[0] = mem_tot;
this.gpu_mem[1] = mem_usd;
});
},
get_amdgpu_gpu_use: function() {

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2023-08-04 22:51+0200\n"
"Last-Translator: Daniel <d3vf4n@tutanota.com>\n"
"Language-Team: \n"
@ -98,6 +98,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Monitor gràfic del sistema"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2023-12-08 07:51+0100\n"
"Last-Translator: Alan Mortensen <alanmortensen.am@gmail.com>\n"
"Language-Team: \n"
@ -98,6 +98,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Systemovervågningsgraf"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2022-04-17 18:13+0100\n"
"Last-Translator: Georg Sieber\n"
"Language-Team: \n"
@ -96,6 +96,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Systemauslastungs-Graph"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2025-08-04 19:01-0400\n"
"Last-Translator: Daniel <d3vf4n@tutanota.com>\n"
"Language-Team: \n"
@ -95,6 +95,10 @@ msgstr "MiB"
msgid "KiB"
msgstr "KiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr "Error al ejecutar el comando nvidia-smi."
#. metadata.json->name
msgid "System monitor graph"
msgstr "Gráfico del monitor de sistema"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2024-11-09 13:32+0200\n"
"Last-Translator: Kimmo Kujansuu <mrkujansuu@gmail.com>\n"
"Language-Team: \n"
@ -98,6 +98,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "System monitor graph"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2025-08-04 10:54+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -95,6 +95,10 @@ msgstr "MiB"
msgid "KiB"
msgstr "KiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Rendszerfigyelő grafikonnal"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2025-08-26 19:59+0200\n"
"Last-Translator: Dragone2 <dragone2@risposteinformatiche.it>\n"
"Language-Team: \n"
@ -95,6 +95,10 @@ msgstr "MiB"
msgid "KiB"
msgstr "KiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Grafico di Monitoraggio del Sistema"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2025-08-25 16:25+0200\n"
"Last-Translator: qadzek\n"
"Language-Team: \n"
@ -93,6 +93,10 @@ msgstr "MiB"
msgid "KiB"
msgstr "KiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Systeemmonitor grafiek"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2021-11-29 15:20-0300\n"
"Last-Translator: Marcelo Aof\n"
"Language-Team: \n"
@ -98,6 +98,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Gráficos do monitor do sistema"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: 2022-04-17 23:21+0200\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
@ -98,6 +98,10 @@ msgstr "GiB"
msgid "KiB"
msgstr "GiB"
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Graficul monitorului de sistem"

View File

@ -4,7 +4,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: \n"
"Last-Translator: blogdron\n"
"Language-Team: \n"
@ -90,6 +90,10 @@ msgstr ""
msgid "KiB"
msgstr ""
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr "Системный монитор с графиками (System monitor graph)"

View File

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: system-monitor-graph@rcassani 2.0\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-08-01 22:18-0400\n"
"POT-Creation-Date: 2025-08-27 21:38-0400\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -93,6 +93,10 @@ msgstr ""
msgid "KiB"
msgstr ""
#. desklet.js:844 desklet.js:882
msgid "Error executing nvidia-smi command."
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr ""