Hi everyone... At work, on our Solaris OS, we have a custom sys.dtwmrc file that controls a custom right-click menu that launches a Java program. I need to edit the dtwmrc file to launch the Java program only if the program is not already running. If the program is already running, I need the program to simply be brought to the front (in front of all open windows).
I am not sure how to do this. After looking all over the internet, and finding basically nothing helpful, I decided to see if anyone here knows how to do this.
I noticed that the dtwmrc file launched programs like "f.exec" and "f.terminal". I need a simple "if statement" to check to see if the Java program is already running. Thing is, I don't know if "if statements" are supported in the dtwmrc file.
Is it possible to write custom functions for the "f." functions in the dtwmrc file? Are the "f.exec" functions compiled C programs, and where are they located on the Solaris OS? Any help would be appreciated, because I really don't know how to solve this problem.
There were no conditional statements I'm aware of with dtwm.
A simple workaround would be to replace the program you f.exec by a script that checks if the process is already running then only launch it if not the case.
I appreciate the response, but this won't work. Granted, it does solve the problem of checking to see if the program is running, but it will not bring the program to the front if it is already running. That is the problem I'm having. I need to bring the program in front of every active window. The only way I know of to do this is using something like "f.raise" in the dtwm, but I can't "interface" with the dtwm in Java code or a shell script.
For example, in shell script pseudo-code, I could put in something like:
"if [ program is not running ] then [ launch program]"
but in the else statement, I don't know how to do something like (or if it is even possible):
"else [ f.raise program ]".
By the way, I didn't mention in my first post that I'm working in the Common Desktop Environment, although you have probably figured that out already.
Thanks... I tried to run "xlswin" on my Solaris machine, but the program isn't installed. Is "xlswin" another Solaris open source C project? If so, do you have a link to the code?
EDIT: I was typing it in wrong... It is "xlswins", not "xlswin".
and click on the window you want to raise.
You get something with window ID and a window name in quotes, e.g. "this is blabla".
Then you can raise it to the top with the command
./xraise "this is blabla"
In your start script put this command in the else branch.
Thanks for the response MadeInGermany. I followed your instructions and downloaded and compiled the C code for xraise. However, I can't get it to work. I ran the "xwininfo" program and got my window's info (it returned 0xc00005 "My Program"). I ran xraise: ./xraise "My Program" but it did nothing. No errors, just sat there (I had to CTRL-C it).
When I compiled the code, I noticed several warnings such as "return makes integer from pointer without a cast". Do you get these cast warnings when you compile the program?
Changing the display variable had no effect. The program still won't do anything. It just hangs. These systems are pretty old, so that may have something to do with it.
I wrote my own C code to raise an X Window with the XRaiseWindow function (Xlib Programming Manual: XRaiseWindow). It works, but only if I hard-code the window's hex value (like 0xc00005) into the program before compiling. If I try to get the window's hex value from argv[] as a parameter, I get a BadWindow error.
Any idea on how to get the window's hex value as a parameter? Code: