Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call out to a command-line program from a gnome shell extension?

I have written a simple shell script to accomplish a common task, and I want to be able to run it whenever a button is clicked. I've used gnome-shell-extension-tool to create the Hello World example already, but now I need to know how to simply have it run an arbitrary command when clicked. There is no input or output to be concerned with; it just needs to run.

like image 706
Jorenko Avatar asked Jun 27 '13 03:06

Jorenko


People also ask

How do you use Gnome Shell Extensions?

Install Gnome ExtensionsFlip the ON switch to install the extension. Install extension by clicking on the ON switch. Click Install to confirm the gnome extension installation. Once installed the extension should appear on your Ubuntu 18.04 Gnome desktop.

How do I access GNOME Shell?

To access GNOME Shell, sign out of your current desktop. From the login screen, click the little button next to your name to reveal the session options. Select the GNOME option in the menu and log in with your password.

How do I open Gnome Extensions?

Hit Alt+F2 keyboard shortcut and then type r and hit Enter to do so. If you open the Gnome Tweaks utility, you will be able to see recently installed extensions. Use the ON/OFF switch to enable/disable the extension.

How do I check my GNOME Shell extension?

You can determine the version of GNOME that is running on your system by going to the About panel in Settings. Open the Activities overview and start typing About. A window appears showing information about your system, including your distribution's name and the GNOME version.


1 Answers

After some more creative googling, I've found the solution:

const Util = imports.misc.util;
Util.spawn(['/path/to/program', 'arg1', 'arg2'])
like image 200
Jorenko Avatar answered Oct 03 '22 03:10

Jorenko