from protocol import Integer, Dictation, RuleRef, RuleType import rules.BaseRules as BaseRules emacsExtras = [ # Note that repetition counts have a minimum of 3 # because if you want twice you can just say the # command followed by "rep". # Small repetition count Integer("i", 3, 8), # Big repetition count Integer("n", 3, 72), # generic integer argument, not used for repetitions Integer("j", 0, 20), Dictation("text"), Dictation("match"), Dictation("replace"), Integer("big", 0, 2**14), RuleRef(BaseRules.CharRule, "charrule"), RuleRef(BaseRules.AlphaRule, "alpharule"), Dictation("match"), Dictation("replace"), ] emacsDefaults = { "n": 1, "i": 1, "text": "", }
from Actions import Key, Text, RepeatPreviousAction from protocol import Integer, RuleType from rules.ContextualRule import makeContextualRule _extras = [ Integer("n", 3, 100), Integer("d", 0, 10), Integer("i", 3, 8), ] _defaults = { "n": 1, "i": 1, } # put the more dangerous stuff by itself _mapping = { "destroy window" : Key("ca-x"), "restart window manager" : Key("csa-q"), "launch emacs" : Key("csa-w"), } XMonadIndependentRule = makeContextualRule("XMonadIndependent", _mapping, _extras, _defaults, ruleType=RuleType.INDEPENDENT) XMonadIndependentRule.activate() _mapping = { # "mon (one | left)" : Key("ca-up"), # "mon (two | middle | center)" : Key("ca-left"), # "mon (three | right)" : Key("ca-right"), # "move mon one [<i>]" : Key("csa-up:%(i)d"),
# log.info("Heard letter! %s" % extras['words']) _mapping = { 'rep [<n>]' : RepeatPreviousAction(), "[control] [alt] [sky] <charrule> [<i>]" : PressKey(), 'scoot [<i>]' : Key("tab:%(i)d"), 'cap scoot [<i>]' : Key("s-tab:%(i)d"), 'greek alpha' : Text("alpha"), 'greek alphas' : Text("alphas"), "click left" : click(1), "click middle" : click(2), "click right" : click(3) } _extras = [ Integer("i", 3, 8), Integer("n", 3, 72), Integer("digit", 0, 10), Dictation("text"), RuleRef(AlphaRule, "alpharule"), RuleRef(CharRule, "charrule"), ] _defaults = { "n": 1, "i": 1, } AlwaysRule = makeContextualRule("Always", _mapping, _extras, _defaults) AlwaysRule.activate()
"per [<n>]": Key("c-left:%(n)d"), "pro [<n>]": Key("c-right:%(n)d"), "chip [<n>]": Key("c-backspace:%(n)d"), "pitch [<n>]": Key("c-delete:%(n)d"), "top side": Key("c-home"), "bottom": Key("c-end"), "save file": Key("c-s"), "open file": Key("c-o"), "new file": Key("c-n"), # Also in the emacs rules, but since emacs rules are mutually exclusive with these # both definition should never be active at the same time. "view <charrule>": CharCmd("(md-select-window-with-glyph %s)"), } _extras = [ Integer("n", 3, 100), Integer("i", 3, 8), Integer("big", 0, 2**14), ] _defaults = { "search_terms": "", "n": 1, "i": 1, } CUARule = makeContextualRule("CUA", _mapping, _extras, _defaults) CUARule.context.addRequirement(NotEmacs) CUARule.context.addRequirement(NotTerminal)
"slap [<n>]": Key("enter:%(n)d"), "history": Key("c-r"), "background": Key("c-z"), "interrupt": Key("c-c,c-c"), "chip [<n>]": Key("c-w:%(n)d"), "pitch [<n>]": Key("a-d:%(n)d"), "run top": Text("top") + Key("enter"), "run H top": Text("htop") + Key("enter"), "switch user": Text("su - "), "C D": Text("cd "), "run D message": Text("dmesg") + Key("enter"), "S S H": Text("ssh "), # Also in the emacs rules, but since emacs rules are mutually exclusive with these # both definition should never be active at the same time. "view <charrule>": CharCmd("(md-select-window-with-glyph %s)"), } _extras = [ Dictation("text"), Integer("n", 3, 20), Integer("i", 3, 8), ] _defaults = { 'n': 1, 'i': 1, } TerminalRule = makeContextualRule("Terminal", _mapping, _extras, _defaults) TerminalRule.context.addRequirement(IsTerminal)