一个方便、漂亮的打印x窗口元数据cli

xpynfo的Python项目详细描述


这是一个简单的cli工具,用于以树格式转储x窗口信息。

当前版本是概念的证明。api可能会发生巨大变化。

功能

系统依赖项

核心功能依赖于libxcbThe ^{tt2}$ docs还提到libxcb-render。我怀疑xcb组件的完整列表实际上是必要的,但是我还没有从新安装中检查。

这里有一个发现RPM世界中依赖关系的好方法。您应该能够在旧系统上用yum替换dnf

$ sudo dnf install -y dnf-utils --allowerasing
# For a full XCB install, use this as the first line instead
#UNLISTED_DEPS=($(eval"echo 'xcb-'{'proto','util-*'}{'','-devel'}"));$UNLISTED_DEPS=($(eval"echo xcb-util-renderutil{,-devel}"));\
DEPS=($(\
        repoquery --requires --resolve python2-xcffib \
| awk -F':''\
                /^[^:]*:[^:]*$/{ \
                    gsub("-[0-9]+$", "", $1); \
                    print $1; \
                }'\
| sort -u \
));\
FULL_DEPS=("${UNLISTED_DEPS[@]}""${DEPS[@]}""${DEPS[@]/%/-devel}")    eval sudo dnf install \
        --skip-broken \
        $(printf"'%s' ""${FULL_DEPS[@]}")
Package xcb-util-renderutil-0.3.9-10.fc28.x86_64 is already installed, skipping.
Package xcb-util-renderutil-devel-0.3.9-10.fc28.x86_64 is already installed, skipping.
Package libxcb-1.13-1.fc28.x86_64 is already installed, skipping.
Package libxcb-1.13-1.fc28.i686 is already installed, skipping.
Package python2-2.7.15-1.fc28.x86_64 is already installed, skipping.
Package python2-cffi-1.11.2-1.fc28.x86_64 is already installed, skipping.
Package python2-six-1.11.0-3.fc28.noarch is already installed, skipping.
Package libxcb-devel-1.13-1.fc28.x86_64 is already installed, skipping.
Package python2-devel-2.7.15-1.fc28.x86_64 is already installed, skipping.
No match for argument: python2-cffi-devel
No match for argument: python2-six-devel
Dependencies resolved.
Nothing to do.
Complete!

# Or, for an even simpler full install,
$ sudo dnf install 'libxcb*''xcb*'

我不知道如何在其他生态系统中做到这一点。应该可以在the Debian worldthe Arch world中进行一些调整。

安装

$ pip install --user xpynfo

用法

$exportPATH=~/.local/bin:$PATH$ which xpynfo
~/.local/bin/xpynfo
$ xpynfo --version
xpynfo <version>
$ xpynfo --help
< dumps all the help >
$ xpynfo \
    --recurse \
    --use-names \
    --style AsciiStyle \
    --max-depth 1\
    --properties \
$(xprop | awk '/WM_CLIENT_LEADER/{ print strtonum($NF); }')# Note: you have to click a window to populate xprop
106954753: Sublime Text
|   Properties:
|       WM_CLASS: ['sublime_text', 'Sublime_text']
|       WM_CLIENT_LEADER: 106954753
|       WM_CLIENT_MACHINE: gxc-fedora-28.wotw
|       WM_COMMAND: sublime_text
|       WM_ICON_NAME: sublime_text
|       WM_LOCALE_NAME: en_US.UTF-8
|       WM_NAME: Sublime Text
|       WM_NORMAL_HINTS: <WM_SIZE_HINTS>
|       WM_PROTOCOLS: ['WM_DELETE_WINDOW', 'WM_TAKE_FOCUS', '_NET_WM_PING']
|       _NET_WM_ICON_NAME: sublime_text
|       _NET_WM_NAME: Sublime Text
|       _NET_WM_PID: 637
|       _NET_WM_USER_TIME_WINDOW: 106954754
+-- 106954754

(非常基本)文档

usage: xpynfo [-h] [-V] [-r] [-d MAX_DEPTH] [-a] [-g] [-p] [-n]
              [-s {AsciiStyle,ContRoundStyle,ContStyle,DoubleStyle}]
              [window_id]

A tool to examine various pieces of X info. Without options the command simply
prints the window id.

positional arguments:
  window_id             Specify the window ID; default is the screen's root
                        window

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         Displays the package version and exits

Scope Control:
  Options to control the scope of the calls xpynfo makes

  -r, --recurse         Also query children of the given ID recursively
  -d MAX_DEPTH, --max-depth MAX_DEPTH
                        Limit the depth of recursion

X Calls:
  Options to add X information

  -a, --attributes      Add XWindowAttributes info to output
  -g, --geometry        Add XGetGeometry info to output
  -p, --properties      Add XListProperties combined with parsed XGetProperty
                        info to output

Style:
  Options to tweak output look

  -n, --use-names       Add _NET_WM_NAME or WM_NAME (when available) to output
  -s {AsciiStyle,ContRoundStyle,ContStyle,DoubleStyle}, --style {AsciiStyle,ContRoundStyle,ContStyle,DoubleStyle}
                        Set the anytree rendering style

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在Android Wifi中筛选相同的SSID?   Java中重写接口中异常处理的泛型   java“无效转义序列(有效的是\b\t\n\f\r\”\“\”\)”语法错误   使用JNDI的java NameReadyBoundException   java如何在这个程序上执行算法   java为什么我的应用程序在调试时崩溃而应用程序停止?   Java:while循环未检测到中断条件,但如果块检测到   java如何快速使用jfreechart创建的折线图   java将输入放入JSTL会话变量,以便稍后在屏幕上显示   java在spring boot中加载外部JAR   java Apache NiFi无法使用ojdbc6连接到Oracle 12c。jar或ojdbc8。罐子   java解释StringToWordVector()Weka的输出   java charAt()找不到符号   使用mpjexpress的java阅读控制台输入