/usr/share/pyshared/Screenkey/modmap.py is in screenkey 0.2-2fakesync1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #!/usr/bin/env python
# Copyright (c) 2010 Pablo Seminario <pabluk@gmail.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
import subprocess
def cmd_keymap_table():
return subprocess.Popen(
['xmodmap','-pk'], stdout=subprocess.PIPE).communicate()[0]
def cmd_modifier_map():
return subprocess.Popen(
['xmodmap','-pm'], stdout=subprocess.PIPE).communicate()[0]
def get_keymap_table():
keymap = {}
keymap_table = cmd_keymap_table()
re_line = re.compile(r'0x\w+')
for line in keymap_table.split('\n')[1:]:
if len(line) > 0:
keycode = re.search(r'\s+(\d+).*', line)
if keycode:
new_keysyms = []
keycode = int(keycode.group(1))
keysyms = re_line.findall(line)
# When you press only one key
unicode_char = ''
try:
unicode_char = unichr(int(keysyms[0], 16))
except:
unicode_char = ''
if unicode_char == u'\x00':
unicode_char = ''
new_keysyms.append(unicode_char)
# When you press a key plus Shift key
unicode_char = ''
try:
unicode_char = unichr(int(keysyms[1], 16))
except:
unicode_char = ''
if unicode_char == u'\x00':
unicode_char = ''
new_keysyms.append(unicode_char)
# When you press a key plus meta (dead keys)
unicode_char = ''
try:
unicode_char = unichr(int(keysyms[4], 16))
except:
unicode_char = ''
if unicode_char == u'\x00':
unicode_char = ''
new_keysyms.append(unicode_char)
# When you press a key plus meta plus Shift key
unicode_char = ''
try:
unicode_char = unichr(int(keysyms[5], 16))
except:
unicode_char = ''
if unicode_char == u'\x00':
unicode_char = ''
new_keysyms.append(unicode_char)
#keymap[keycode-8] = new_keysyms
keymap[keycode] = new_keysyms
return keymap
def get_modifier_map():
modifiers = {}
modifier_map = cmd_modifier_map()
re_line = re.compile(r'(0x\w+)')
for line in modifier_map.split('\n')[1:]:
if len(line) > 0:
mod_name = re.match(r'(\w+).*', line)
if mod_name:
mod_name = mod_name.group(1)
keycodes = re_line.findall(line)
# Convert key codes from hex to dec for use them
# with the keymap table
keycodes =[ int(kc, 16) for kc in keycodes]
modifiers[mod_name] = keycodes
return modifiers
|