when I run the command uname-r
in gnome-terminal.
I get the result as 6.6.1-arch-1
.
$ uname -r
6.6.1-arch1-1
$
I have created a gnome-shell-extension inside which I am calling the command below
const obj = GLib.spawn_command_line_sync('uname -r');
Main.notify('', JSON.stringify(obj)); // testing purpose
const kernelText = `Kernel Version ${obj[1].toString().trim()}`;
The obj I am getting is like this
How can I get the text with out this line,
const kernelText = `Kernel Version ${obj[1].toString().trim()}`;
GLib.spawn_command_line_sync()
returns an array of four values: a success boolean, stdout as aUint8Array
, stderr as aUint8Array
and the wait status as aNumber
.There is a guide for Spawning Subprocesses in GJS, or you may want to use
GLib.get_os_info()
if you're using it to spawnuname
.Spawning a synchronous subprocess in an extension is highly discouraged and will probably not pass review.