編輯:這會檢測何時顯示窗口;但是當所有的菜單/裏面的部件都完成了佈局/佈局
確定沒有檢測,所以首先我運行此腳本:
audacity &
pid=$!
while [ "1" ] ; do
xwininfo -name 'Audacity'
sleep 0.1
done
...應該是這樣運行,以獲得一個完整的日誌:
bash testscript.sh 2>&1 | tee testscript.log
...並可以看到一個點,其中來自xwininfo
「過渡」,轉儲可以這麼說:
xwininfo: Window id: 0x3a000b5 (has no name)
Absolute upper-left X: 0
Absolute upper-left Y: 0
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 200
Height: 200
Depth: 24
Visual: 0x21
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsUnMapped
Override Redirect State: no
Corners: +0+0 -824+0 -824-400 +0-400
-geometry 200x200+0+0
xwininfo: Window id: 0x4c00587 "Audacity"
Absolute upper-left X: 50
Absolute upper-left Y: 59
Relative upper-left X: 0
Relative upper-left Y: 18
Width: 830
Height: 540
Depth: 24
Visual: 0x21
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0x20 (installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +50+59 -144+59 -144-1 +50-1
-geometry 830x540+50-1
所以,我基本上可以grep
不包含xwininfo
輸出「沒有名字」,或者包含「映射的狀態:IsViewable」 ......
所以,我終於嘗試這一點 - 它似乎工作:
audacity &
pid=$!
WINREP=""
while [[ ! "`echo $WINREP | grep -l 'Map State: IsViewable'`" ]] ; do
WINREP=$(xwininfo -name 'Audacity')
#echo $WINREP
sleep 0.1
done
echo Exited
# must use -F here for case-insensitive, to ensure proper window targetting
wmctrl -v -F -r "Audacity" -e 0,0,0,800,600