From c28ddfe8986767049810e3c1f514ce01cf05d547 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 27 Jan 2009 00:47:45 +0000 Subject: [PATCH] * Tue Jan 27 2009 Peter Hutterer 1.5.99.901-5 - replace fedora-setup-keyboard with pure python one (#478431) --- fedora-setup-keyboard | 69 ++++++++++++++++++++++++++----------------- xorg-x11-server.spec | 5 +++- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/fedora-setup-keyboard b/fedora-setup-keyboard index 22ebcf2..945af89 100644 --- a/fedora-setup-keyboard +++ b/fedora-setup-keyboard @@ -1,33 +1,48 @@ -#!/bin/sh -# -# Trivial egregious hack to load the console keyboard layout into XKB. -# -# Yes, this should really just be written in python. If you can figure -# out how to make hal callouts written in python _work_, then please -# let me know. In the meantime, we'll do this. +#!/usr/bin/env python +# encoding: utf-8 +# vim: tabstop=4 expandtab autoindent shiftwidth=4 fileencoding=utf-8 +""" +fedora-setup-keyboard.py -[[ -x /usr/bin/python ]] || exit 0 -[[ -x /usr/bin/hal-set-property ]] || exit 0 +Written by Alexander D. Kanevskiy +""" -source /etc/sysconfig/keyboard >& /dev/null || exit 0 +import sys, os, dbus +import rhpl.keyboard_models +from rhpl.simpleconfig import SimpleConfigFile -[[ -n "$KEYTABLE" ]] || exit 0 +KBDCONFIG = "/etc/sysconfig/keyboard" -rhplquery () { - /usr/bin/python -c "import rhpl.keyboard_models; m = rhpl.keyboard_models.KeyboardModels().get_models(); print \"junk='%s' layout='%s' model='%s' variant='%s' options='%s'\" % tuple(m[\"$1\"])" || echo "exit 0" -} +def main(): + # Sanity checks + if 'UDI' not in os.environ: + sys.exit(1) + if not os.access(KBDCONFIG, os.R_OK): + sys.exit(0) + # Read config + kbd_config = SimpleConfigFile() + kbd_config.read(KBDCONFIG) + kbd_models = rhpl.keyboard_models.KeyboardModels().get_models() + (layout, model, variant, options) = tuple(kbd_models.get(kbd_config.info.get('KEYTABLE',''), ['', '', '', '', ''])[1:]) + result_dict = { 'layout': layout, 'model': model, 'variant': variant, 'options': options } + + # Now let's dbus fun begin + if 'HALD_DIRECT_ADDR' in os.environ: + bus = dbus.connection.Connection(os.environ['HALD_DIRECT_ADDR']) + else: + bus = dbus.SystemBus() + kbd = dbus.Interface(bus.get_object("org.freedesktop.Hal", os.environ['UDI']), 'org.freedesktop.Hal.Device') + for key in result_dict: + # Respect user settings + value = kbd_config.info.get(key.upper(), result_dict[key]) + if not value: + try: + kbd.RemoveProperty("input.xkb.%s" % key) + except dbus.exceptions.DBusException: + pass # key already not exist + else: + kbd.SetPropertyString("input.xkb.%s" % key, value) -eval `rhplquery $KEYTABLE` -hal_set () { - if [[ -n "${!1}" ]]; then - /usr/bin/hal-set-property --direct --udi "$UDI" --key input.xkb.$1 --string "${!1}" - else - /usr/bin/hal-set-property --direct --udi "$UDI" --key input.xkb.$1 --remove - fi -} - -hal_set layout -hal_set model -hal_set variant -hal_set options +if __name__ == '__main__': + main() diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index 8cf7885..038a250 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -19,7 +19,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.5.99.901 -Release: 4%{?dist} +Release: 5%{?dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -494,6 +494,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Jan 27 2009 Peter Hutterer 1.5.99.901-5 +- replace fedora-setup-keyboard with pure python one (#478431) + * Tue Jan 27 2009 Dave Airlie 1.5.99.901-4 - xserver-1.5.99.3-fix-core-fonts.patch (#478999)