Skip to content

Instantly share code, notes, and snippets.

@jacmoe
Forked from tim-tx/qutebrowser_remap.py
Created February 27, 2023 09:54
Show Gist options
  • Save jacmoe/ab141e438986136b570e74eb3dc84235 to your computer and use it in GitHub Desktop.
Save jacmoe/ab141e438986136b570e74eb3dc84235 to your computer and use it in GitHub Desktop.
Remap qutebrowser default keybindings to colemak
qwerty_to_colemak = {
'Q': 'Q',
'W': 'W',
'E': 'F',
'R': 'P',
'T': 'G',
'Y': 'J',
'U': 'L',
'I': 'U',
'O': 'Y',
'P': ':',
'A': 'A',
'S': 'R',
'D': 'S',
'F': 'T',
'G': 'D',
'H': 'H',
'J': 'N',
'K': 'E',
'L': 'I',
':': 'O',
'Z': 'Z',
'X': 'X',
'C': 'C',
'V': 'V',
'B': 'B',
'N': 'K',
'M': 'M',
'q': 'q',
'w': 'w',
'e': 'f',
'r': 'p',
't': 'g',
'y': 'j',
'u': 'l',
'i': 'u',
'o': 'y',
'p': ';',
'a': 'a',
's': 'r',
'd': 's',
'f': 't',
'g': 'd',
'h': 'h',
'j': 'n',
'k': 'e',
'l': 'i',
';': 'o',
'z': 'z',
'x': 'x',
'c': 'c',
'v': 'v',
'b': 'b',
'n': 'k',
'm': 'm',
',': ',',
'.': '.',
'/': '/',
'+': '+',
'-': '-',
'=': '=',
'?': '?',
'@': '@',
'^': '^',
'[': '[',
']': ']',
'`': '`',
"'": "'",
'"': '"',
'{': '{',
'}': '}',
'$': '$',
'0': '0',
'1': '1',
'2': '2',
'3': '3',
'4': '4',
'5': '5',
'6': '6',
'7': '7',
'8': '8',
'9': '9',
}
with open("config.py") as fp:
lines = fp.readlines()
for line in lines:
line = line[:-1]
if not line.startswith("config."):
print(line)
continue
i = 14
delim = line[12]
while line[i] is not delim:
i += 1
s = line[13:i]
x = s
if not (s.startswith("<") and s.endswith(">")):
x = "".join([qwerty_to_colemak[t] for t in s])
else:
t = s[1:-1]
if t[-2] == "-":
t = t[:-1] + qwerty_to_colemak[t[-1]]
x = "<" + t + ">"
print(line[:12] + delim + x + delim + line[(i+1):])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment