sx-bind

With sx-bind, you can bind keystrokes to actions. Its plugin key is “bind”.

Dependencies

sx-bind depends on sx-actions.

Provided Parameters

There is just one parameter that sx-bind provides in its parameter dictionary: ‘screen’ is the samuraix.screen.Screen object the keystroke was pressed on.

Configuration

bind.keys

A dictionary connecting Keystrokes to action lines.

Example:

'bind.keys': {
        'Meta+n': 'desktops.cycle offset=1',
        'Meta+p': 'desktops.cycle offset=-1',
        'Meta+c': 'desktops.cycle_clients',
        'Meta+d': 'log message="pressed d"',
        'Meta+Q': 'quit',
        'Ctrl+R': 'restart',
        'Meta+L': 'layoutmgr.cycle',
}

Keystrokes

A keystroke describes a combination of modifier keys and one normal key pressed. They are joined together by a “+” char. The modifiers are case-insensitive, the key is not.

Valid modifier names are: ‘alt’, ‘numlock’, ‘meta’, ‘altgr’, ‘shift’, ‘lock’, ‘ctrl’, ‘control’, ‘mod1’, ‘mod2’, ‘mod3’, ‘mod4’, ‘mod5’.

The valid key values are listed in the ooxcb documentation.

Examples:

# the following three keystrokes are equal
Meta+n
META+n
mEtA+n
# some more examples
SHIFT+metA+0
Ctrl+alt+Delete
class sxbind.SXBind(app)
bind_key_to_action(modifiers, keycode, line)
if the modifiers in the mask modifiers are pressed down, and the key with the keycode keycode is pressed down, emit the action line line.
bind_keystroke(keystroke, line)
bind the keystroke keystroke to the action line line. keystroke has to be in the format that is described under parse_keystroke().
on_key_press(event)
Event handler: if it is a bound key, emit the corresponding action line. If it is not, print a warning to the log.
on_load_config(config)
Event handler: (re-)load the configuration.
on_ready(app)
Event handler: everything’s ready, setup the event handlers.
setup_handlers()
setup the on_key_press handlers for the root window.
sxbind.parse_keystroke(s)

Return (modifiers, keysym), extracted from the string s.

It has to contain several modifiers and keysym names, joined together with a ‘+’:

CTRL+A
MOD4+q

samurai-x

Table Of Contents

Previous topic

sx-autoclient

Next topic

sx-bookmarks

This Page