If I run these commands:
...
geany --new-instance --no-msgwin --no-session --no-terminal -c pathtoconfig/ &
pid=$!
echo $pid
wmctrl -lp
read -p "waiting..."
...
the resulting PID does not match that of the geany process launched. But if a sleep 1 command is inserted before reading the PID (after the geany line), then the PID is correct. The reason for this is that windowing takes some time, so wmctrl -lp provides preliminary information which does not much precisely the right PID.
What would be the best way to wait for geany to complete launching before the new window has stabilized and wmctrl is aware of it?
Update: - Run on Lubuntu 16.04 / HP ProBook 6360b.
Actual PID for comparison was obtained with
wmctrl -lpthat includes PID in the list.PID is fetched correctly by
$!, what takes some time to update is the one provided bywmctrl -lp, that is different after some time (some 0.27s forgeany, some 0.16s forleafpad), as if the window manager would take some time to update the PID.