Ubuntu :: Bash For Programs Running In Terminal?Aug 9, 2011
Trying to write a script for desktop launchers that are adaptable to screen resolution. Ideally, the program should:
1. Determine screen resolution:
if "a" use xdotool options window size 1305 x 869 px and move to 135,0
if "b" use xdotool options window size 1545 x 1019 px and move to 135,0
2. Check if program running:
if no, open program, and use "a" or "b" placement options, focus window
if yes, focus window
3. Close script and leave program open (if possible).
Problems arise when trying to use the script on programs that run from and hog the terminal
(e.g. brasero, gcalctool, nautilus)
Here the script will load the program, and nothing else (probably because it still occupies the terminal as it runs)
gcalctool && xdotool search "calculator" windowmove 135 0
This next command will cause the program to load, move, but it keeps focusing itself like xdotool is running the windowmove function constantly - it keeps focusing itself until script stopped.
gcalctool & xdotool search "calculator" windowmove 135 0
This had the same effect as the above code, but seems to work as a conditional subscript running when the process is running in the terminal - it just goes infinitely.
while  ; do xdotool search "calculator" windowmove 135 0 done exit
Is there some kind of "if, then" or "while, do" or some kind of conditional I can put in to the script ensure the window is moved only once if the program is running within the terminal? Is there a way to remove the program from the terminal from the script once it's been called?