fixed Alt_L not working

This commit is contained in:
sezanzeb 2020-12-03 01:32:36 +01:00 committed by sezanzeb
parent 70f091f39b
commit 3e48d899ea
2 changed files with 13 additions and 3 deletions

View File

@ -41,7 +41,12 @@ def populate_system_mapping():
xmodmap = subprocess.check_output(['xmodmap', '-pke']).decode() + '\n' xmodmap = subprocess.check_output(['xmodmap', '-pke']).decode() + '\n'
mappings = re.findall(r'(\d+) = (.+)\n', xmodmap) mappings = re.findall(r'(\d+) = (.+)\n', xmodmap)
for keycode, names in mappings: for keycode, names in mappings:
for name in names.split(): # there might be multiple, like:
# keycode 64 = Alt_L Meta_L Alt_L Meta_L
# keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
# only the first column is relevant. The others can be achieved
# by using a modifier button and the mapped key
name = names.split()[0]
mapping[name] = int(keycode) - XKB_KEYCODE_OFFSET mapping[name] = int(keycode) - XKB_KEYCODE_OFFSET
for name, ecode in evdev.ecodes.ecodes.items(): for name, ecode in evdev.ecodes.ecodes.items():

View File

@ -37,7 +37,12 @@ class TestMapping(unittest.TestCase):
self.assertGreater(len(mapping), 100) self.assertGreater(len(mapping), 100)
self.assertEqual(mapping['1'], 2) self.assertEqual(mapping['1'], 2)
self.assertEqual(mapping['KEY_1'], 2) self.assertEqual(mapping['KEY_1'], 2)
self.assertEqual(mapping['KEY_LEFTSHIFT'], mapping['Shift_L'])
self.assertEqual(mapping['Alt_L'], 56)
self.assertEqual(mapping['KEY_LEFTALT'], 56)
self.assertEqual(mapping['KEY_LEFTSHIFT'], 42)
self.assertEqual(mapping['Shift_L'], 42)
def test_clone(self): def test_clone(self):
mapping1 = Mapping() mapping1 = Mapping()