I want to be able to have a keyboard short-cut to either start or bring to the front a program. (sqldeveloper if it matters)
I know how to run it, that leaves:
1) how do I find out if a program is already running?
2) how do I bring the program the other top of other open windows?
~~ edit ~~
Thanks for the responses so far. When I run either of those commands to get the list of running processes, I get the following:
doneill 3492 1 0 Nov16 ? 00:00:00 /bin/sh /usr/local/bin/sqldeveloper
doneill 3493 3492 0 Nov16 ? 00:00:00 /bin/bash /opt/sqldeveloper/sqldeveloper.sh
doneill 3495 3493 0 Nov16 ? 00:00:00 bash sqldeveloper
doneill 3552 3495 1 Nov16 ? 00:25:07 /usr/lib/jvm/java-6-sun-1.6.0.22/bin/java -Xmx640M -Xms128M -Xverify:none -Doracle.ide.util.AddinPolicyUtils.OVERRIDE_FLAG=true -Dsun.java2d.ddoffscreen=false -Dwindows.shell.font.languages= -XX:MaxPermSize=128M -Dide.AssertTracingDisabled=true -Doracle.ide.util.AddinPolicyUtils.OVERRIDE_FLAG=true -Djava.util.logging.config.file=logging.conf -Dsqldev.debug=false -Dide.conf="/opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf" -Dide.startingcwd="/opt/sqldeveloper/sqldeveloper/bin" -classpath ../../ide/lib/ide-boot.jar oracle.ide.boot.Launcher
I do launch it via the .sh script. It is a java based program. Which of those are the one I'd be interested in? I tried using the xdotool
to raise it, I haven't been successful yet, although I don't have time tonight to dig into the man pages.
If I run xdotool search Orac
('Oracle SQL Developer' is the start to the title of the window), it returns a bunch of numbers. Do one of these represent what I'm interested in?
A little bash and xdotool should do the trick. Notes on installing xdotool at end of post.
ActivateOrLaunch.sh
You can find the code on github
I tested the code on Ubuntu 10.10 (Gnome) and it worked. It need some polishing since I just typed it up and wasn't worried about making it pretty (wanted to make sure to get the comments in)
To install xdotool you can apt-get install xdotool (form me this fetched version 2.20100701.2691), if you want the latest and greatest get it from here (as of 20101116 it's as version 2.20101012.3049-4)
Create a file in your home directory called sql-raise.sh
The line starting
if ps -ef...
translates to:process-name
grep
command itself, to prevent false positivesThe line starting
xdotool
is the one which brings the process to the front.On a command line execute
chmod +x ~/sql-raise.sh
to make the file executable.To bind this to a key, use the System -> Preferences -> Keyboard Shortcuts
'launchorsitch.sh firefox' starts firefox if it isn't running, switches to it, if it isn't active or minimizes it if it's the active window.
At the beginning there are special rules for programs (here it's terminator). My hack uses wmctrl and allows to specify special rules for what executable to look for/run. Any comments on style, obvious mistakes etc welcome.