Exemple #1
0
def parse_layout(symbol):
    xcb = XKeyboard()
    groups = xcb.groups_symbols
    assert groups
    assert symbol in groups, '%s: invalid layout. Select one from %r' \
                             % (symbol, groups)
    return symbol
Exemple #2
0
def change_layout(xkb: xkbgroup.XKeyboard, layout: str) -> bool:
    """Set layout; returns True if layout was changed, False otherwise"""
    if xkb.group_name == layout:  # check against current layout
        log.debug("%r is already the active layout", layout)
        return False  # don't change layout if it's already correct
    log.info("setting layout %r", layout)
    xkb.group_name = layout
    notify("Changed layout", layout)
    return True
Exemple #3
0
    def do_keypresses(self):
        if self.keys and not self.haspressedkeys:
            self.haspressedkeys = True
            if has_xkbgroup:
                with XKeyboard() as xkb:
                    logging.info("xkb %d:%s:%s", xkb.group_num, xkb.group_symbol, xkb.group_name)
            keys = self.keys.split("]")
            for key in keys:
                if (key):
                    key = key[1:]
                    keyparts = key.split(" ")
                    mods = []
                    for part in keyparts:
                        if part in self.known_keys:
                            mainkey = part
                        elif part in self.known_modifiers:
                            mods.append(part)
                    logging.info("key is %s with modifiers %s" % (mainkey, mods))
                    keyval = self.known_keys[mainkey]
                    logging.info("%s", keyval)
                    for modifier in mods:
                        modkeypress = KeyPressAction(self.known_modifiers[modifier])
                        modkeypress._keyPress(self.known_modifiers[modifier])

                    mainkeypress = KeyPressAction(keyval)
                    mainkeyrelease = KeyReleaseAction(keyval)
                    mainkeypress._keyPress(keyval)
                    mainkeyrelease._keyRelease(keyval)

                    for modifier in mods:
                        modkeypress = KeyReleaseAction(self.known_modifiers[modifier])
                        modkeypress._keyRelease(self.known_modifiers[modifier])

                    time.sleep(0.05)

            t = Timer(1.0, self.do_destroy)
            t.start()
Exemple #4
0
    def init(self):
        if self.layouts:
            self.set_layouts(self.layouts)

        self._xkb = XKeyboard(auto_open=True)
 def __init__(self):
     self._last_id = -1
     self._lang_state = {}
     self._xkb = XKeyboard()
Exemple #6
0
def set_default(symbol):
    xcb = XKeyboard()
    xcb.group_symbol = symbol
Exemple #7
0
    def __init__(self):
        self.xkb = XKeyboard()
        self.controller = Controller()
        self.state = state.StateMachine()

        self.busy = False