【问题标题】:Python/Linux - Check if some other app is fullscreenPython/Linux - 检查其他应用程序是否全屏
【发布时间】:2021-04-12 07:53:36
【问题描述】:

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

我已经让整个控制器在后台启动并运行,但我一直在试图弄清楚如何确定是否有某个应用程序在全屏运行。我该怎么做?我在 Debian 测试中使用 python3。

非常感谢您的帮助!

【问题讨论】:

    标签: python linux debian


    【解决方案1】:

    我找到了答案here 并对其进行了一些修改以使其更有用。这是我在 gnome 上工作的代码。您可能需要调整其他 gdms 的转义窗口名称。

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      • 2012-12-16
      • 2013-01-05
      • 2019-03-11
      • 2021-06-22
      • 2014-02-19
      • 1970-01-01
      相关资源
      最近更新 更多