Popping up the GNOME “Run Application” dialog from a script

2004 July 24
by darkness

So apparently there used to be a gnome-run command that would let you pop up the GNOME “Run Application” dialog. Then I guess this dialog got integrated into the panel, and then this program went away. On Gnome 2.6 (I think?) on FC2 there’s no obvious way to do this. I dug in gnome-panel sources a bit and found a CORBA interface… that I don’t know how to use. (Bonobo couldn’t find my desired component. I wonder if this interface is broken.) Then I looked at how Metacity did it and I made gnome-run.c. Compile it with something like gcc gnome-run.c -o gnome-run -L/usr/X11R6/lib -lX11. I then set Sawfish up to run that when I hit M-Esc and set up a matched window declaration for it that focuses it when it appears. All is well.

Shame on GNOME for making this so hard. I think I’m going to look at switching to KDE/Konsole later — with Sawfish as my WM still. Sawfish does rule.

12 Comments leave one →
2005 May 8
Ben West permalink

is there a way to do this so the command runs on another machine. I run this via “ssh user@host -X -f gnome-run” but the command runs locally even though gnome-run is on the remote machine.

2005 May 13

Ben West : if you want a graphic command on a remote computer using ssh, you have to use the DISPLAY variable. So you should try “ssh user@host -f DISPLAY=:0 gnome-run”

2005 May 13

We discussed this via e-mail, and I think the problem is that gnome-run works by sending a message to the root window. Obviously, that root window is on your X server on your local box. Your local gnome-panel (I think) then intercepts that message and produces the run dialog. To have it pop up a run dialog that corresponds to the remote machine, you’d have to have a gnome-panel running from that machine as well… which would be weird.

2005 June 18
Jon Hermansen permalink

Hit Alt+F2…

2007 November 28

It works. But the Run window is not bring to top. What code I need to add to have it shows up on in front of other window (like using Alt+F2)? TIA.

2007 November 28
darkness permalink

Good question. I’m afraid I don’t know what code would be necessary to make this pop to the front–or if that’s even possible. It often seems rude when windows try to pop up front and take focus without my permission, and I believe many window managers (including my window manager of choice, Sawfish) have options to try and prevent this.

Sawfish also has a “matched windows” functionality that allows you to match certain characteristics of windows, such as title, and perform certain actions on those windows, like bringing them to the front and focusing them when they appear. I use this functionality to bring my gnome-run window to the front and focus it. Other window managers may have something like this too; for example, Gnome’s default window manager Metacity has Devil’s Pie[1].

Sorry I couldn’t be of more help.

darkness

[1] http://www.burtonini.com/blog/computers/devilspie

2007 November 28

> It often seems rude when windows try to pop up front and take focus without my permission

It doesn’t make sense. Of course it’s not rude, because you click it on purpose. It’s user driven event. After a few hours dug the xlib programming tutorials, I found the cause. It’s because you set the launch time (l[1] argument) to zero! That’s why the window never got focus. The window manager think that it was already clicked years ago! :D By setting it to current time, it works perfectly! Now I don’t need to install devilspie or configure compiz’s windows matches. Thanks for the code. :)

2007 November 28
darkness permalink

> It doesn’t make sense. Of course it’s not rude, because you click it on purpose. It’s user driven event.

I guess the idea is that the run dialog should always have focus? In general, just because I “click” on something does not mean I want it to be in the front and have focus. For example, if you start up some program that takes a while to run (say, oowriter) you may have already gone off to do something else (e.g. work on an e-mail in a terminal window). It would be annoying if, mid-keystroke, oowriter took focus (which it does anyway, harumph). I guess the run dialog could be special, though.

Anyway, the way in which it’s decided what should and shouldn’t get focus is clearly something I don’t understand. I’m guessing that this “time” you speak of indicates when the event was sent, and if something like a focus change happens after that time (the time of the last focus change, or some other event, presumably being tracked by the X server and/or window manager?) focus is not changed? So by setting it to the current time, especially on a fast computer, you should have no problems. That’s just my guess though.

At any rate, thanks for looking in to this and posting your results here. I’m sure others will find it helpful (maybe including me).

2007 November 28

[...] google took me to this blog. The blog owner has a small program to pop up Gnome’s Run Command dialog. As it’s a [...]

Pingback
2008 February 24
Harrison permalink

Try this shell command too:

`zenity –entry –text=”Run command:” –width=400`

2008 March 18

This worked great, but bee was right that it needed to be set to the current time. Try this:

- Copy gnome-run.c to a folder.
- Edit gnome-run.c, line 37:
“event.data.l[1] = (Time)0;”
change to “event.data.l[1] = (Time)(time(NULL) * 1000);”
- Open terminal window
- Navigate to folder with gnome-run.c
- Type: gcc gnome-run.c -o gnome-run -L/usr/X11R6/lib -lX11
- Type: sudo mv gnome-run /usr/bin/

Optional to make it work like Windows’ Start-Run command
- Right-click “Applications” menu in Panel.
- Click Edit Menus
- Click New Item
- In the Create Launcher window type Name: Run, Command: gnome-run, press OK
- In Main Menu window move the Run command to the top if your panel is at the top of your screen, or to whatever other location you want.
- You can repeat this process for gksu and call it “Run As”

2008 April 21
yyj permalink

see all the comment here,still not find a way to popup the run dialog

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS