Esempio n. 1
0
def count_on_current_ws(ignored_classes: List[str], ewmh: EWMH) -> int:
    """
    Count the number of open windows on the current workspace.

    Windows with a class in the given ignore list, bad windows,
    or ones missing a _NET_WM_DESKTOP property are not counted.

    :param ignored_classes: A list of window classes to ignore
    :param ewmh: An instance of EWMH for workspace retrieval
    :return: The number of open windows on the workspace
    """
    window_count = 0

    all_windows = ewmh.getClientList()
    windows_on_ws = [
        w for w in all_windows
        if get_workspace(w, ewmh) == ewmh.getCurrentDesktop()
    ]

    for window in windows_on_ws:
        try:
            window_class = window.get_wm_class()
        except Xlib.error.BadWindow:
            logging.info('Ignoring bad window (id: %s)', window.id)
            continue

        if window_class is not None and window_class[1] in ignored_classes:
            logging.info("Ignoring window with class '%s'.", window_class[1])
            continue

        window_count += 1

    return window_count
Esempio n. 2
0
from helper.gtk import setup_win, loop
import helper.gtk as helper

ewmh = EWMH()
disp = ewmh.display

lst = glob.glob('./cropped/*.png')
lst.sort()


def setup_win(workspace_id, image_path):
    xid = helper.setup_win(image_path)
    name = os.path.split(image_path)[1].replace(' ', '')

    win_x = disp.create_resource_object("window", xid)
    ewmh.setWmDesktop(win_x, workspace_id)
    win_x.set_wm_class('notile', 'notile')


ci = ewmh.getCurrentDesktop()
wins = []
for i in range(ewmh.getNumberOfDesktops()):
    if i == ci:
        continue
    setup_win(i, lst[i])
setup_win(ci, lst[ci])

disp.flush()

helper.loop()
Esempio n. 3
0
#!/usr/bin/python
from ewmh import EWMH

ewmh = EWMH()
print(ewmh.getCurrentDesktop())