答案1wmctrl -lG
会给你:oli@bert:~$ wmctrl -lG
0x0384c0d5 -1 1590 1030 330 170 bert N/A
0x01200023 -1 0 0 3840 1200 bert x-nautilus-desktop
0x01000003 -1 3840 2352 1920 24 bert Bottom Expanded Edge Panel
0x01000028 -1 0 2352 1920 24 bert Bottom Expanded Edge Panel
0x0500003e 0 676 252 1404 1015 bert Chromium
0x02e00021 0 3860 160 1361 1084 bert Liferea
0x02000047 0 6650 940 506 683 bert Social broadcast messages
0x04600004 0 4546 460 1263 833 bert oli@bert: ~
答案2
这就是说,下面是几个打印出活动窗口大小的脚本。
wmctrl+xdotool... (不使用sed )。id=$(xdotool getactivewindow)
wmctrl -lpG | while read -a a; do w=${a[0]}; if (($((16#${w:2}))==id)) ; then echo -n"${a[5]} ${a[6]}"; break; fi; done
这是:xwininfo xdotool sed
xwininfo是x11-utils的一部分set $(xwininfo -id $(xdotool getactivewindow)
|sed -n -e"s/^ +Width: ([0-9]+).*/1/p"
-e"s/^ +Height: ([0-9]+).*/1/p")
echo -n"$1 $2"
答案3
使用xprop或xwininfo。两者都可以直接使用,不需要安装
用法示例:
这两个命令都将光标转换为方形/十字,以允许选择特定的窗口。$ xprop _NET_WM_OPAQUE_REGION
_NET_WM_OPAQUE_REGION(CARDINAL) = 0, 0, 984, 377
$ xwininfo | awk -F ':' '/Width/ || /Height/{print $2}'
984
377
或者,可以在XID表单中指定命令行上的window$ xprop _NET_WM_OPAQUE_REGION -id 83886090
_NET_WM_OPAQUE_REGION(CARDINAL) = 0, 0, 984, 377
$ xwininfo -id 83886090 | awk -F ':' '/Width/ || /Height/{print $2}'
984
377
相关文章