如何在命令行中获取所有打开窗口的列表?

如何从命令行生成包括对话框和重复窗口在内的所有打开窗口的列表?
1个回答

你可以使用 wmctrl 来获取所有打开的窗口列表。您首先需要将其安装好。
sudo apt install wmctrl

然后你只需要运行这个命令。
wmctrl -l

0x0080006a -1 localhost panel
0x0180007c  0 localhost Mozilla Firefox
0x02600007  3 localhost user@localhost: /home/user - Shell - Konsole
0x00600011  1 localhost KTorrent
0x02200007  0 localhost user@localhost: /home/user - Shell - Konsole
1           2 3         4

列: 1. 窗口ID。用于[#i -i]开关。 2. 桌面ID。从0开始计数。-1表示该窗口在所有桌面上。与[#d -d]等一起使用。 3. 客户端机器 4. 窗口的名称(长标题)。主要与[#r -r]一起使用,并可使用[#N -N]和[#T -T]进行重命名。
更多示例:wmctrl-examples