예제 #1
0
def windows(result_fun, prefix_complete=False, homogenous=False, 
            current_desk=False):
    global currentPrompt

    desks = range(0, ewmh.get_number_of_desktops().reply())
    names = ewmh.get_desktop_names().reply()

    content = {}
    for d in desks:
        if current_desk and state.desktop != d:
            continue

        name = d
        if d < len(names):
            name = names[d]

        content[name] = []

    clients = ewmh.get_client_list_stacking().reply()
    for c in reversed(clients):
        nm = ewmh.get_wm_desktop(c).reply()
        if nm < len(names):
            nm = names[nm]
        if nm in content:
            wm_name = ewmh.get_wm_name(c).reply()
            if not wm_name:
                wm_name = icccm.get_wm_name(c).reply()
            if not wm_name or not isinstance(wm_name, basestring):
                wm_name = 'N/A'
            content[nm].append((wm_name, c))

    currentPrompt = Prompt(content, result_fun, prefix_complete, homogenous)
예제 #2
0
    def fun(name):
        names = ewmh.get_desktop_names().reply()
        if name not in names:
            names.append(name)
            ewmh.set_desktop_names_checked(names).check()
            num_desks = ewmh.get_number_of_desktops().reply()
            ewmh.request_number_of_desktops_checked(num_desks + 1).check()

        ewmh.request_wm_desktop_checked(activewin, 
                                        names.index(name), 2).check()
예제 #3
0
    def fun(name):
        names = ewmh.get_desktop_names().reply()
        if name not in names:
            names.append(name)
            ewmh.set_desktop_names_checked(names).check()
            num_desks = ewmh.get_number_of_desktops().reply()
            ewmh.request_number_of_desktops_checked(num_desks + 1).check()

        ewmh.request_wm_desktop_checked(activewin, names.index(name),
                                        2).check()
예제 #4
0
def set_or_add_desktop(name):
    names = ewmh.get_desktop_names().reply()

    if name not in names:
        names.append(name)
        ewmh.set_desktop_names_checked(names).check()
        num_desks = ewmh.get_number_of_desktops().reply()
        ewmh.request_number_of_desktops_checked(num_desks + 1).check()

    ewmh.request_current_desktop_checked(names.index(name)).check()
예제 #5
0
def set_or_add_desktop(name):
    names = ewmh.get_desktop_names().reply()

    if name not in names:
        names.append(name)
        ewmh.set_desktop_names_checked(names).check()
        num_desks = ewmh.get_number_of_desktops().reply()
        ewmh.request_number_of_desktops_checked(num_desks + 1).check()

    ewmh.request_current_desktop_checked(names.index(name)).check()
예제 #6
0
def desktops(result_fun, prefix_complete=True, homogenous=True):
    global currentPrompt

    desks = range(0, ewmh.get_number_of_desktops().reply())
    names = ewmh.get_desktop_names().reply()
    lst = []
    for d in desks:
        nm = names[d] if d < len(names) else d
        lst.append((nm, nm))

    currentPrompt = Prompt({ None: sorted(lst) }, result_fun, prefix_complete,
                           homogenous)
예제 #7
0
파일: state.py 프로젝트: inktrap/pytyle3
def cb_property_notify(e):
    global activewin, desk_num, desktop, monitors, phys_monitors, root_geom, stacking, visibles, workarea

    aname = util.get_atom_name(e.atom)
    if aname == "_NET_DESKTOP_GEOMETRY":
        root_geom = ewmh.get_desktop_geometry().reply()
        monitors = xinerama.get_monitors()
        phys_monitors = xinerama.get_physical_mapping(monitors)
    elif aname == "_NET_ACTIVE_WINDOW":
        activewin = ewmh.get_active_window().reply()
    elif aname == "_NET_CURRENT_DESKTOP":
        desktop = ewmh.get_current_desktop().reply()
        if visibles is None or len(visibles) == 1:
            visibles = [desktop]
    elif aname == "_NET_VISIBLE_DESKTOPS":
        visibles = ewmh.get_visible_desktops().reply()
    elif aname == "_NET_NUMBER_OF_DESKTOPS":
        desk_num = ewmh.get_number_of_desktops().reply()
    elif aname == "_NET_CLIENT_LIST_STACKING":
        stacking = ewmh.get_client_list_stacking().reply()
    elif aname == "_NET_WORKAREA":
        update_workarea()
예제 #8
0
def cb_property_notify(e):
    global activewin, desk_num, desktop, monitors, phys_monitors, root_geom, \
           stacking, visibles, workarea

    aname = util.get_atom_name(e.atom)
    if aname == '_NET_DESKTOP_GEOMETRY':
        root_geom = ewmh.get_desktop_geometry().reply()
        monitors = xinerama.get_monitors()
        phys_monitors = xinerama.get_physical_mapping(monitors)
    elif aname == '_NET_ACTIVE_WINDOW':
        activewin = ewmh.get_active_window().reply()
    elif aname == '_NET_CURRENT_DESKTOP':
        desktop = ewmh.get_current_desktop().reply()
        if visibles is None or len(visibles) == 1:
            visibles = [desktop]
    elif aname == '_NET_VISIBLE_DESKTOPS':
        visibles = ewmh.get_visible_desktops().reply()
    elif aname == '_NET_NUMBER_OF_DESKTOPS':
        desk_num = ewmh.get_number_of_desktops().reply()
    elif aname == '_NET_CLIENT_LIST_STACKING':
        stacking = ewmh.get_client_list_stacking().reply()
    elif aname == '_NET_WORKAREA':
        update_workarea()
예제 #9
0
def remove_empty_current_desktop():
    # This isn't as straight-forward as decrementing _NET_NUMBER_OF_DESKTOPS.
    # We need to make sure we remove the right name, too.
    # AND only do it if there are no clients on this desktop.
    clients = ewmh.get_client_list().reply()
    cur = ewmh.get_current_desktop().reply()
    for c in clients:
        if ewmh.get_wm_desktop(c).reply() == cur:
            return

    names = ewmh.get_desktop_names().reply()
    if cur < len(names):
        names.pop(cur)
        ewmh.set_desktop_names_checked(names).check()

    # Subtract one from every client's desktop above the current one
    for c in clients:
        cdesk = ewmh.get_wm_desktop(c).reply()
        if cdesk > cur and cdesk != 0xffffffff:
            ewmh.set_wm_desktop_checked(c, cdesk - 1).check()

    ndesks = ewmh.get_number_of_desktops().reply()
    ewmh.request_number_of_desktops_checked(ndesks - 1).check()
예제 #10
0
def remove_empty_current_desktop():
    # This isn't as straight-forward as decrementing _NET_NUMBER_OF_DESKTOPS.
    # We need to make sure we remove the right name, too.
    # AND only do it if there are no clients on this desktop.
    clients = ewmh.get_client_list().reply()
    cur = ewmh.get_current_desktop().reply()
    for c in clients:
        if ewmh.get_wm_desktop(c).reply() == cur:
            return

    names = ewmh.get_desktop_names().reply()
    if cur < len(names):
        names.pop(cur)
        ewmh.set_desktop_names_checked(names).check()

    # Subtract one from every client's desktop above the current one
    for c in clients:
        cdesk = ewmh.get_wm_desktop(c).reply()
        if cdesk > cur and cdesk != 0xffffffff:
            ewmh.set_wm_desktop_checked(c, cdesk - 1).check()

    ndesks = ewmh.get_number_of_desktops().reply()
    ewmh.request_number_of_desktops_checked(ndesks - 1).check()
예제 #11
0
def cb_prop_change(widget, e):
    global activewin, desk_names, desk_num, desktop, stacking, visibles

    if e.atom == '_NET_DESKTOP_GEOMETRY':
        root_geom = ewmh.get_desktop_geometry().reply()
        update_monitor_area()
    elif e.atom == '_NET_ACTIVE_WINDOW':
        activewin = ewmh.get_active_window().reply()
    elif e.atom == '_NET_CURRENT_DESKTOP':
        desktop = ewmh.get_current_desktop().reply()
    elif e.atom == '_NET_CLIENT_LIST_STACKING':
        stacking = ewmh.get_client_list_stacking().reply()
    elif e.atom == '_NET_VISIBLE_DESKTOPS':
        visibles = ewmh.get_visible_desktops().reply()
    elif e.atom in ('_NET_DESKTOP_NAMES', '_NET_NUMBER_OF_DESKTOPS'):
        desk_num = ewmh.get_number_of_desktops().reply()
        desk_names = ewmh.get_desktop_names().reply()

        # This works around what I think is weird behavior in Openbox.
        # Sometimes Openbox will "fix" the desktop names... please don't!
        if len(desk_names) > desk_num:
            names = desk_names[0:desk_num]
            ewmh.set_desktop_names_checked(names).check()
        desk_names = ewmh.get_desktop_names().reply()
예제 #12
0
def cb_prop_change(widget, e):
    global activewin, desk_names, desk_num, desktop, stacking, visibles

    if e.atom == '_NET_DESKTOP_GEOMETRY':
        root_geom = ewmh.get_desktop_geometry().reply()
        update_monitor_area()
    elif e.atom == '_NET_ACTIVE_WINDOW':
        activewin = ewmh.get_active_window().reply()
    elif e.atom == '_NET_CURRENT_DESKTOP':
        desktop = ewmh.get_current_desktop().reply()
    elif e.atom == '_NET_CLIENT_LIST_STACKING':
        stacking = ewmh.get_client_list_stacking().reply()
    elif e.atom == '_NET_VISIBLE_DESKTOPS':
        visibles = ewmh.get_visible_desktops().reply()
    elif e.atom in ('_NET_DESKTOP_NAMES', '_NET_NUMBER_OF_DESKTOPS'):
        desk_num = ewmh.get_number_of_desktops().reply()
        desk_names = ewmh.get_desktop_names().reply()

        # This works around what I think is weird behavior in Openbox.
        # Sometimes Openbox will "fix" the desktop names... please don't!
        if len(desk_names) > desk_num:
            names = desk_names[0:desk_num]
            ewmh.set_desktop_names_checked(names).check()
        desk_names = ewmh.get_desktop_names().reply()
예제 #13
0
            wm = ewmh.get_wm_name(childw).reply()
            if wm.lower() == 'openbox':
                utilwm = window.WindowManagers.Openbox
            elif wm.lower() == 'kwin':
                utilwm = window.WindowManagers.KWin

            print '%s window manager is running...' % wm
            sys.stdout.flush()

    if not _wmrunning:
        time.sleep(1)

root_geom = ewmh.get_desktop_geometry().reply()
monitors = xinerama.get_monitors()
phys_monitors = xinerama.get_physical_mapping(monitors)
desk_num = ewmh.get_number_of_desktops().reply()
activewin = ewmh.get_active_window().reply()
desktop = ewmh.get_current_desktop().reply()
visibles = ewmh.get_visible_desktops().reply() or [desktop]
stacking = ewmh.get_client_list_stacking().reply()
workarea = []

def quit():
    print 'Exiting...'
    import tile
    for tiler in tile.tilers:
        tile.get_active_tiler(tiler)[0].untile()
    sys.exit(0)

def update_workarea():
    '''
예제 #14
0
def getNumberOfDesktops():
    return ewmh.get_number_of_desktops().reply()
예제 #15
0
def getNumberOfDesktops():
    return ewmh.get_number_of_desktops().reply()
import xpybutil.xinerama as xinerama
 
c.core.ChangeWindowAttributes(root, xcb.xproto.CW.EventMask,
                              [xcb.xproto.EventMask.PropertyChange])
c.flush()
 
sleep = False
visibles = None
while visibles is None:
    if sleep:
        time.sleep(1)
 
    currentdesk = ewmh.get_current_desktop().reply()
    visibles = ewmh.get_visible_desktops().reply()
    names = ewmh.get_desktop_names().reply()
    deskcnt = ewmh.get_number_of_desktops().reply()
    sleep = True
 
def do_output(visibles, currentdesk, names, deskcnt):
    out_visible = []
    out_hidden = []
 
    for visible in visibles:
        if visible == currentdesk:
            out_visible.append(markup['current'] % names[visible])
        else:
            out_visible.append(markup['visible'] % names[visible])
 
    clients = ewmh.get_client_list().reply()
    nonemptydesks = set()
    for client in clients: