Created
January 9, 2022 20:38
-
-
Save mijorus/312a5ac5dd22878a4740fd6bd395c40c to your computer and use it in GitHub Desktop.
How to run a command from a gnome extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
The first time I wanted to create an extension for Gnome, I spent two hours trying to understand how to do this, due to bad documentation. | |
So now I am sharing this once for all. | |
*/ | |
const ByteArray = imports.byteArray; | |
function exec(command) { | |
const output = GLib.spawn_command_line_sync(command); | |
return { | |
ok: output[0], | |
standard_output: ByteArray.toString(output[1]), | |
standard_error: ByteArray.toString(output[2]), | |
exit_status: output[3] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment