#!/usr/bin/env python # -*- encoding: utf-8 -*- # Copyright (c) 2008 Saleem Abdulrasool # Very simple script which converts the InputDevice section for keyboards into a # FDI rule. Any time a specific model is present, we ignore it and set it to # evdev, as that will be the driver used. import sys import xf86config from xf86config import XF86SectionMissing def xkb_model(value): model = ' ' % (value,) + '\n' model += ' evdev' return model def xkb_rules(value): return ' %s' % (value,) def xkb_layout(value): return ' %s' % (value,) def xkb_options(values): options = ' %s' % (values.split(',')[0]) for value in values.split(',')[1:]: options += '\n' + ' %s' % (value,) return options def xkb_variant(value): return ' %s' % (value,) if __name__ == '__main__': OptionHandlers = { 'XkbModel' : xkb_model, 'XkbRules' : xkb_rules, 'XkbLayout' : xkb_layout, 'XkbOptions' : xkb_options, 'XkbVariant' : xkb_variant, } (configuration, path) = xf86config.readConfigFile() if not configuration: sys.stderr.write("Failed to read xorg.conf\n") sys.exit(-1) try: keyboard = xf86config.getCoreKeyboard(configuration) except XF86SectionMissing: sys.stderr.write("No CoreKeyboard\n") sys.exit(-1) rule = '' + '\n' rule += '' + '\n' rule += ' ' + '\n' for option in keyboard.options: if option.name in OptionHandlers: rule += OptionHandlers[option.name](option.val) + '\n' else: sys.stderr.write('Failed to translate: %s %s\n' % (option.name, option.val)) rule += ' ' + '\n' rule += '' + '\n' print rule # vim: set ts=3 sw=3 et nowrap: