convert-map revision a180a41bba1d50822df23fff0099e90b86638b89
963N/A#!/usr/bin/env python2
499N/A# -*-Python-*-
499N/A#
919N/A# Copyright 2001 Peter Åstrand <astrand@cendio.se> for Cendio AB
919N/A#
919N/A# This program is free software; you can redistribute it and/or modify
919N/A# it under the terms of the GNU General Public License as published by
919N/A# the Free Software Foundation; version 2 of the License.
919N/A#
919N/A# This program is distributed in the hope that it will be useful,
919N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
919N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
919N/A# GNU General Public License for more details.
919N/A#
919N/A# You should have received a copy of the GNU General Public License
919N/A# along with this program; if not, write to the Free Software
919N/A# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
919N/A
919N/Aimport sys
919N/A
499N/Adef main():
499N/A f = open(sys.argv[1])
499N/A while 1:
499N/A line = f.readline()
499N/A if not line: break
499N/A
499N/A if line.startswith("#") or line.startswith("include"):
499N/A print line,
499N/A continue
499N/A
499N/A fields = line.split()
499N/A
499N/A if line.startswith("map"):
499N/A print "map 0x%s" % fields[1]
499N/A continue
499N/A
499N/A scancode = fields[0]
499N/A for pos in range(1, len(fields)):
499N/A keysym = fields[pos]
499N/A
499N/A if pos == 1:
963N/A modifiers = ""
499N/A elif pos == 2:
499N/A modifiers = "shift"
499N/A elif pos == 3:
963N/A modifiers = "altgr"
499N/A elif pos == 4:
modifiers = "shift altgr"
else:
raise("Invalid line: %s" % line)
print "%s 0x%s %s" % (keysym, scancode, modifiers)
if __name__ == "__main__":
if len(sys.argv) < 2:
print "Convert old-style keymaps to new style"
print "Usage: %s <old-style-keymap>" % sys.argv[0]
sys.exit(1)
else:
main()