-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
60 lines (51 loc) · 2.51 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
from ulauncher.api.shared.event import KeywordQueryEvent
from ulauncher.api.shared.action.HideWindowAction import HideWindowAction
import subprocess
class KeyboardLayoutChange(Extension):
def __init__(self):
super().__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
class KeywordQueryEventListener(EventListener):
def on_event(self, event, extension):
query = event.get_query().strip()
if query == extension.preferences['kus']:
subprocess.Popen(['setxkbmap', 'us', '-variant', 'alt-intl'])
elif query == extension.preferences['kit']:
subprocess.Popen(['setxkbmap', 'it'])
elif query == extension.preferences['kes']:
subprocess.Popen(['setxkbmap', 'es'])
elif query == extension.preferences['kfr']:
subprocess.Popen(['setxkbmap', 'fr'])
elif query == extension.preferences['kpl']:
subprocess.Popen(['setxkbmap', 'pl'])
elif query == extension.preferences['kde']:
subprocess.Popen(['setxkbmap', 'de'])
elif query == extension.preferences['kdha']:
subprocess.Popen(['setxkbmap', 'us', '-variant', 'colemak_dh'])
elif query == extension.preferences['kdhi']:
subprocess.Popen(['setxkbmap', 'us', '-variant', 'colemak_dh_iso'])
elif query == extension.preferences['ja']:
subprocess.Popen(['setxkbmap', 'ja'])
elif query == extension.preferences['he']:
subprocess.Popen(['setxkbmap', 'he'])
elif query == extension.preferences['ru']:
subprocess.Popen(['setxkbmap', 'ru'])
elif query == extension.preferences['sv']:
subprocess.Popen(['setxkbmap', 'sv'])
elif query == extension.preferences['sl']:
subprocess.Popen(['setxkbmap', 'sl'])
elif query == extension.preferences['ch']:
subprocess.Popen(['setxkbmap', 'ch'])
elif query == extension.preferences['sq']:
subprocess.Popen(['setxkbmap', 'sq'])
elif query == extension.preferences['be']:
subprocess.Popen(['setxkbmap', 'be'])
elif query == extension.preferences['da']:
subprocess.Popen(['setxkbmap', 'da'])
elif query == extension.preferences['nl']:
subprocess.Popen(['setxkbmap', 'nl'])
return HideWindowAction()
if __name__ == '__main__':
KeyboardLayoutChange().run()