fdservices
IS-IT--Management
I am trying to add some code which will run the programme called unless it is already running, in which case it simply raises the existing instance. So far I have tried wmctrl as follows:
# if wmctrl is loaded then use it to raise an already running application
if {[catch {exec which wmctrl}] == 0} {
set process [pid]
set program [file tail $argv0]
set list [split [exec ps -eo "pid cmd" | grep "$program"] \n]
foreach i $list {
if {[string first $process [string trim $i]] == 0} {continue}
if {[string first grep $i] != -1} {continue}
if {[string first "wish" $i] != -1 && [string first "$program" $i] != -1} {exec wmctrl -a "Window Title"; exit}
}
}
It works well when the existing instance is running iconified, but if it already "active" then it remains buried under any other windows. I need something to make the programme instance active and above all other windows. I tried looking at xprop, but did not have much luck there either.
Any ideas?
Andrew
# if wmctrl is loaded then use it to raise an already running application
if {[catch {exec which wmctrl}] == 0} {
set process [pid]
set program [file tail $argv0]
set list [split [exec ps -eo "pid cmd" | grep "$program"] \n]
foreach i $list {
if {[string first $process [string trim $i]] == 0} {continue}
if {[string first grep $i] != -1} {continue}
if {[string first "wish" $i] != -1 && [string first "$program" $i] != -1} {exec wmctrl -a "Window Title"; exit}
}
}
It works well when the existing instance is running iconified, but if it already "active" then it remains buried under any other windows. I need something to make the programme instance active and above all other windows. I tried looking at xprop, but did not have much luck there either.
Any ideas?
Andrew