日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux查看正在运行的窗口,获取linux中打开的应用程序窗口的数量

發布時間:2025/3/12 linux 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux查看正在运行的窗口,获取linux中打开的应用程序窗口的数量 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我想檢測由窗口管理器管理的特定應用程序的實例數量.目前,我有這個:

#!/bin/bash

# wmctrl required

pids=$(pidof $1)

IFS=' ' read -a pid_arr <<< "$pids"

matches=0

for pid in "${pid_arr[@]}"

do

matching_lines=$(wmctrl -l -p | egrep -c "^.+\b.+\b$pid\b")

matches=$((matches + $matching_lines))

done

echo $matches

假設我有三次打開firefox并且我將firefox作為參數傳遞,如果沒有打開“子窗口”(例如首選項窗口),該函數將只返回正確的數字.否則,該函數也將計算這些窗口.

我想獲得沒有“子窗口”的窗口數量.

P.S.:做了一些改變.要計算沒有對話窗口的窗口數,這是我目前的解決方案:

#!/bin/bash

pids=$(pidof $1)

IFS=' ' read -r -a pid_arr <<< "$pids"

matches=0

for pid in "${pid_arr[@]}"

do

ids=$(wmctrl -l -p | awk '$3=='$pid'{printf $1" "}')

IFS=' ' read -r -a id_arr <<< "$ids"

for id in "${id_arr[@]}"

do

if ! xprop -id "$id" |

egrep -q '(WM_TRANSIENT_FOR|_NET_WM_WINDOW_TYPE_DIALOG)'

then

((matches++))

fi

done

done

echo $matches

但是在firefox的情況下,腳本無法區分瀏覽器窗口及其首選項窗口,因為它們都不是對話框窗口.

上面的腳本對我來說已經足夠了,因為我用它來弄清楚xfce4-appfinder有多少個窗口(沒有對話窗口).對于xfce4-appfinder,腳本可以正常工作,因為它的首選項窗口很容易被識別為對話框窗口.在firefox中,甚至可以通過調用firefox -preferences獨立打開首選項窗口.將這樣的窗口識別為某種“子窗口”可能是不可能的.

以下是我對firefox的瀏覽器和首選項窗口的xprop和xwininfo的結果:

xwininfo(瀏覽器):

xwininfo: Window id: 0x1c0007f "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"

Root window id: 0xa1 (the root window) (has no name)

Parent window id: 0x1400048 (has no name)

1 child:

0x1c00080 (has no name): () 1x1+-1+-1 +1+37

Absolute upper-left X: 2

Absolute upper-left Y: 38

Relative upper-left X: 0

Relative upper-left Y: 14

Width: 956

Height: 511

Depth: 24

Visual: 0x20

Visual Class: TrueColor

Border width: 0

Class: InputOutput

Colormap: 0x22 (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: +2+38 -962+38 -962-531 +2-531

-geometry 956x511+0+22

Bit gravity: NorthWestGravity

Window gravity: NorthWestGravity

Backing-store hint: NotUseful

Backing-planes to be preserved: 0xffffffff

Backing pixel: 0

Save-unders: No

Someone wants these events:

KeyPress

KeyRelease

ButtonPress

ButtonRelease

EnterWindow

LeaveWindow

PointerMotion

Exposure

VisibilityChange

StructureNotify

FocusChange

PropertyChange

Do not propagate these events:

Override redirection?: No

Window manager hints:

Client accepts input or input focus: Yes

Initial state is Normal State

Displayed on desktop 0

Window type:

Normal

Process id: 792 on host T530

Normal window size hints:

Program supplied minimum size: 300 by 71

Program supplied maximum size: 32767 by 32767

Program supplied window gravity: NorthWestGravity

No zoom window size hints defined

No window shape defined

No border shape defined

xwininfo(首選項):

xwininfo: Window id: 0x1c046ef "Firefox Preferences"

Root window id: 0xa1 (the root window) (has no name)

Parent window id: 0x1400060 (has no name)

1 child:

0x1c046f0 (has no name): () 1x1+-1+-1 +961+37

Absolute upper-left X: 962

Absolute upper-left Y: 38

Relative upper-left X: 0

Relative upper-left Y: 14

Width: 956

Height: 1040

Depth: 24

Visual: 0x20

Visual Class: TrueColor

Border width: 0

Class: InputOutput

Colormap: 0x22 (installed)

Bit Gravity State: NorthWestGravity

Window Gravity State: NorthWestGravity

Backing Store State: NotUseful

Save Under State: no0x1c00001

Map State: IsViewable

Override Redirect State: no

Corners: +962+38 -2+38 -2-2 +962-2

-geometry 956x1040-0-0

Bit gravity: NorthWestGravity

Window gravity: NorthWestGravity

Backing-store hint: NotUseful

Backing-planes to be preserved: 0xffffffff

Backing pixel: 0

Save-unders: No

Someone wants these events:

KeyPress

KeyRelease

ButtonPress

ButtonRelease

EnterWindow

LeaveWindow

PointerMotion

Exposure

VisibilityChange

StructureNotify

FocusChange

PropertyChange

Do not propagate these events:

Override redirection?: No

Window manager hints:

Client accepts input or input focus: Yes

Initial state is Normal State

Displayed on desktop 0

Window type:

Normal

Process id: 792 on host T530

Normal window size hints:

Program supplied location: 0, 0

Program supplied minimum size: 604 by 594

Program supplied maximum size: 32767 by 32767

Program supplied window gravity: NorthWestGravity

No zoom window size hints defined

No window shape defined

No border shape defined

xprop(瀏覽器):

_DESKTOP(CARDINAL) = 0

WM_STATE(WM_STATE):

window state: Normal

icon window: 0x0

WM_HINTS(WM_HINTS):

Client accepts input or input focus: True

Initial state is Normal State.

bitmap id # to use for icon: 0x1c00082

bitmap id # of mask for icon: 0x1c00083

window id # of group leader: 0x1c00001

_NET_STARTUP_ID(UTF8_STRING) = "xfce4-appfinder/|usr|lib|firefox|firefox/756-0-T530_TIME21351"

WM_WINDOW_ROLE(STRING) = "browser"

XdndAware(ATOM) = BITMAP

_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29360257

_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL

_NET_WM_USER_TIME(CARDINAL) = 1758669

_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c00080

WM_CLIENT_LEADER(WINDOW): window id # 0x1c00001

_NET_WM_PID(CARDINAL) = 792

WM_LOCALE_NAME(STRING) = "en_US.UTF-8"

WM_CLIENT_MACHINE(STRING) = "T530"

WM_NORMAL_HINTS(WM_SIZE_HINTS):

program specified minimum size: 300 by 71

program specified maximum size: 32767 by 32767

window gravity: NorthWest

WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST

WM_CLASS(STRING) = "Navigator", "Firefox"

WM_ICON_NAME(STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"

_NET_WM_ICON_NAME(UTF8_STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"

WM_NAME(STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"

_NET_WM_NAME(UTF8_STRING) = "bash - Get number of opened application windows in linux - Stack Overflow - Mozilla Firefox"

xprop(首選項)

_NET_WM_DESKTOP(CARDINAL) = 0

WM_STATE(WM_STATE):

window state: Normal

icon window: 0x0

WM_HINTS(WM_HINTS):

Client accepts input or input focus: True

Initial state is Normal State.

bitmap id # to use for icon: 0x1c046f2

bitmap id # of mask for icon: 0x1c046f3

window id # of group leader: 0x1c00001

WM_WINDOW_ROLE(STRING) = "Preferences"

XdndAware(ATOM) = BITMAP

_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 29378289

_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL

_NET_WM_USER_TIME(CARDINAL) = 1456410

_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1c046f0

WM_CLIENT_LEADER(WINDOW): window id # 0x1c00001

_NET_WM_PID(CARDINAL) = 792

WM_LOCALE_NAME(STRING) = "en_US.UTF-8"

WM_CLIENT_MACHINE(STRING) = "T530"

WM_NORMAL_HINTS(WM_SIZE_HINTS):

program specified location: 0, 0

program specified minimum size: 604 by 594

program specified maximum size: 32767 by 32767

window gravity: NorthWest

WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST

WM_CLASS(STRING) = "Browser", "Firefox"

WM_ICON_NAME(STRING) = "Firefox Preferences"

_NET_WM_ICON_NAME(UTF8_STRING) = "Firefox Preferences"

WM_NAME(STRING) = "Firefox Preferences"

_NET_WM_NAME(UTF8_STRING) = "Firefox Preferences"

總結

以上是生活随笔為你收集整理的linux查看正在运行的窗口,获取linux中打开的应用程序窗口的数量的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 91在线免费观看网站 | 口述3p做爰全过程 | 亚洲欧美日韩第一页 | 国产欧美熟妇另类久久久 | 成人久久影院 | 视频黄页在线观看 | 亚洲天堂99| 美女久久久 | 国产乱淫av一区二区三区 | 久久久久久久国产精品 | 多啪啪免费视频 | 国产成人精品影院 | 男女在线免费观看 | 最近中文字幕在线中文高清版 | 鲁啊鲁在线视频 | 大黑人交xxx极品hd | 欧美jizzhd欧美18 | 国产美女引诱水电工 | 长腿校花无力呻吟娇喘的视频 | 免费成人在线播放 | 美女涩涩视频 | 97精品国产97久久久久久粉红 | 哪里可以免费看毛片 | 深夜在线观看 | av在线不卡网站 | 国内特级毛片 | 久久99久| aaaa毛片| 亚洲第一综合网站 | 蜜臀av性久久久久蜜臀aⅴ涩爱 | 青草视频在线播放 | 少妇人妻好深好紧精品无码 | 一区二区三区www | 午夜神马影院 | 综合亚洲视频 | 高清av网址 | 欧美99| 亚洲成人av免费观看 | 午夜不卡福利 | 电影《走路上学》免费 | 日韩操操操| 国产成人短视频在线观看 | 女女同性女同一区二区三区按摩 | 最新激情网 | 欧美性猛交久久久乱大交小说 | 亚洲精品久久久久久国 | 特级西西444www高清大胆 | 日本少妇喂奶 | 在线观看少妇 | 欧美一区二区三区在线视频 | 男生把女生困困的视频 | 在线免费看毛片 | 久久九九综合 | 大波大乳videos巨大 | 色图视频| 国产嫩草影院久久久久 | 久久大片 | 啪啪综合网 | 色偷偷人人澡人人爽人人模 | 17c精品麻豆一区二区免费 | 在线观看成人免费 | 一区二区三区视频免费在线观看 | 国产男人天堂 | 久久精品国内 | 免费精品视频一区二区三区 | 三级视频黄色 | 福利视频第一页 | 麻豆乱码国产一区二区三区 | 国产成人精品在线观看 | 激情成人av| 天堂在线观看免费视频 | 欧美精品自拍视频 | 精品人妻一区二区三区蜜桃 | 波多野结衣av电影 | 精品少妇人妻av免费久久洗澡 | 久久久国产高清 | 在线观看污视频网站 | 午夜视频在线看 | 久久你懂的 | 乱码一区二区三区 | 国产精品一二三区在线观看 | 中文字幕二区在线观看 | 曰韩一级片 | 国产一级久久 | 国产精品高潮视频 | 噜噜噜久久| 久久久女人 | 亚洲精品无码永久在线观看 | 日韩欧美成人一区 | av女大全列表| 精品久久久久久久久久久久久久久久久 | 日本在线视频免费 | 精品国产免费视频 | 亚洲图片在线播放 | 天堂中文8 | 中文字幕制服丝袜 | 亚洲欧美日韩精品永久在线 | 国产96在线 | 久久久久中文字幕 |