Orcsome instance api

class orcsome.core.WM

Core orcsome instance

Can be get in any time as:

import orcsome
wm = orcsome.get_wm()
activate_window_desktop(window)

Activate window desktop

Return:

  • True if window is placed on different from current desktop
  • False if window desktop is the same
  • None if window does not have desktop property
change_window_desktop(window, desktop)

Move window to desktop

close_window(window)

Send request to wm to close window

current_desktop

Return current desktop number

Counts from zero.

current_window

Return currently active (with input focus) window

decorate_window(window, decorate=True)

Decorate/undecorate window

Parameters:decorate – undecorate window if False

Note

Openbox specific.

find_client(clients, **matchers)

Return first matching client

Parameters:
find_clients(clients, **matchers)

Return matching clients list

Parameters:
focus_and_raise(window)

Activate window desktop, set input focus and raise it

focus_window(window)

Activate window

get_atom(atom_name)

Return atom value

get_atom_name(atom)

Return atom string representation

get_clients()

Return wm client list

get_stacked_clients()

Return client list in stacked order.

Most top window will be last in list. Can be useful to determine window visibility.

get_window_desktop(window)

Return window desktop.

Result is:

  • number from 0 to desktop_count - 1
  • -1 if window placed on all desktops
  • None if window does not have desktop property
get_window_role(window)

Return WM_WINDOW_ROLE property

get_window_state(window)

Return WindowState instance

get_window_title(window)

Return _NET_WM_NAME property

is_match(window, name=None, cls=None, role=None, desktop=None, title=None)

Check if window suits given matchers.

Matchers keyword arguments are used in on_create(), spawn_or_raise(). find_clients() and find_client().

name
window name (also referenced as instance). The first part of WM_CLASS property.
cls
window class. The second part of WM_CLASS property.
role
window role. Value of WM_WINDOW_ROLE property.
desktop
matches windows placed on specific desktop. Must be int.
title
window title.

name, cls, title and role can be regular expressions.

on_create(*args, **matchers)

Signal decorator to handle window creation

Can be used in two forms. Listen to any window creation:

@wm.on_create
def debug(wm):
    print wm.event_window.get_wm_class()

Or specific window:

@wm.on_create(cls='Opera')
def use_firefox_luke(wm):
    wm.close_window(wm.event_window)
    spawn('firefox')()

Also, orcsome calls on_create handlers on its startup. You can check wm.startup attribute to denote such event.

See is_match() for **matchers argument description.

on_destroy(window)

Signal decorator to handle window destroy

on_key(*args)

Signal decorator to define hotkey

You can define global key:

wm.on_key('Alt+Return')(
    spawn('xterm'))

Or key binded to specific window:

@wm.on_create(cls='URxvt')
def bind_urxvt_keys():
    # Custom key to close only urxvt windows
    wm.on_key(wm.event_window, 'Ctrl+d')(
        close)

Key defenition is a string in format [mod + ... +]keysym where mod is one of modificators [Alt, Shift, Control(Ctrl), Mod(Win)] and keysym is a key name.

on_property_change(*args)

Signal decorator to handle window property change

One can handle any window property change:

@wm.on_property_change('_NET_WM_STATE')
def window_maximized_state_change():
    state = wm.get_window_state(wm.event_window)
    if state.maximized_vert and state.maximized_horz:
        print 'Look, ma! Window is maximized now!'

And specific window:

@wm.on_create
def switch_to_desktop():
    if not wm.startup:
        if wm.activate_window_desktop(wm.event_window) is None:
            # Created window has no any attached desktop so wait for it
            @wm.on_property_change(wm.event_window, '_NET_WM_DESKTOP')
            def property_was_set():
                wm.activate_window_desktop(wm.event_window)
                property_was_set.remove()
place_window_above(window)

Float up window in wm stack

place_window_below(window)

Float down window in wm stack

set_current_desktop(num)

Activate desktop num

orcsome.core.WindowState

Window state

Has following attributes:

maximized_vert
Is window maximized vertically.
maximized_horz
Is window maximized horizontally.
undecorated
Is window does not have decorations (openbox specific state).

alias of State

Previous topic

Actions

Next topic

FAQ

This Page