Python/Linux-检查其他应用程序是否全屏

Python/Linux-检查其他应用程序是否全屏,python,linux,debian,Python,Linux,Debian,我已经为显示器背面的RGB LED开发了一个控制器,我想控制它们,以便在运行全屏应用程序(如电影)时,它们与屏幕上的平均颜色相匹配 我已经在后台安装并运行了整个控制器,但我一直在想如何确定是否有某个应用程序在全屏运行。我怎么做呢?我正在Debian测试中使用python3 非常感谢你的帮助 我找到了一个答案,并对其进行了一些修改,使其更易于使用。这是我在gnome上的代码。您可能需要调整其他GDM的转义窗口名称 import Xlib.display #Find out if fullscre

我已经为显示器背面的RGB LED开发了一个控制器,我想控制它们,以便在运行全屏应用程序(如电影)时,它们与屏幕上的平均颜色相匹配

我已经在后台安装并运行了整个控制器,但我一直在想如何确定是否有某个应用程序在全屏运行。我怎么做呢?我正在Debian测试中使用python3

非常感谢你的帮助

我找到了一个答案,并对其进行了一些修改,使其更易于使用。这是我在gnome上的代码。您可能需要调整其他GDM的转义窗口名称

import Xlib.display

#Find out if fullscreen app is running
screen = Xlib.display.Display().screen()
root_win = screen.root

def is_fullscreen():
    #cycle through all windows
    for window in root_win.query_tree()._data['children']:
        width = window.get_geometry()._data["width"]
        height = window.get_geometry()._data["height"]

        #if window is full screen, check it the window name
        if width == screen.width_in_pixels and height == screen.height_in_pixels:
            if window.get_wm_name() in ['Media viewer', 'mutter guard window']:
                continue
            #return true if window name is not one of the gnome windows
            return True
    #if we reach this, no fs window is open
    return False