首页 > 解决方案 > 使用 `python-xlib` 模拟 `xprop` 和 `wmctrl` 用于窗口 `above` 的函数

问题描述

我是新手python-xlib。一年来我一直在使用gtk, gdk,xdotool和. 现在我想通过.wmctrlxpropxlib

我有这个功能我想转换但不知道如何转换成xlib命令。

def win_remove_above(win_hex):
    """  If window 'above' (Always on Top in Ubuntu-speak) toggle it off
         and return True. Otherwise return None
    """
    was_above = None
    all_lines = os.popen('xprop -id ' + win_hex).read().strip().splitlines()
    for line in all_lines:
        if "_NET_WM_STATE(ATOM)" in line:
            # print('line:', line)
            if "ABOVE" in line:
                was_above = True
                os.popen('wmctrl -ir ' + win_hex + ' -b toggle,above')
            break

    return was_above

标签: pythonx11xlibwmctrl

解决方案


推荐阅读