db4f70f2c6
works continue..
107 lines
3.3 KiB
Diff
107 lines
3.3 KiB
Diff
Index: zorg-2.0.4/zorg/config.py
|
|
===================================================================
|
|
--- zorg-2.0.4.orig/zorg/config.py
|
|
+++ zorg-2.0.4/zorg/config.py
|
|
@@ -11,6 +11,21 @@ from zorg.parser import *
|
|
from zorg.probe import VideoDevice, Monitor, Output
|
|
from zorg.utils import *
|
|
|
|
+KEYMAP_CONF_TEMPLATE="""\
|
|
+# This file is generated by zorg. If you want to change settings
|
|
+# in this file, edit the file 10-keyboard.conf in the same
|
|
+# directory.
|
|
+
|
|
+Section "InputClass"
|
|
+ Identifier "Configured Keymap"
|
|
+ MatchIsKeyboard "on"
|
|
+ MatchTag "use_configured_keymap"
|
|
+
|
|
+ %(comment_layout)sOption "xkb_layout" "%(layout)s"
|
|
+ %(comment_variant)sOption "xkb_variant" "%(variant)s"
|
|
+EndSection
|
|
+"""
|
|
+
|
|
def saveXorgConfig(card):
|
|
parser = XorgParser()
|
|
|
|
@@ -265,7 +280,7 @@ def saveDeviceInfo(card):
|
|
f = open(consts.config_file, "w")
|
|
f.write(doc.toPrettyString().replace("\n\n", ""))
|
|
|
|
-def getKeymap():
|
|
+def getKeymapOld():
|
|
layout = None
|
|
variant = ""
|
|
|
|
@@ -297,24 +312,44 @@ def getKeymap():
|
|
|
|
return layout, variant
|
|
|
|
-def saveKeymap(layout, variant=""):
|
|
- if not os.path.exists(consts.config_dir):
|
|
- os.mkdir(consts.config_dir, 0755)
|
|
+def getKeymap():
|
|
+ layout = None
|
|
+ variant = ""
|
|
|
|
try:
|
|
- doc = piksemel.parse(consts.config_file)
|
|
+ p = XorgParser()
|
|
+ p.parseFile(consts.keymap_conf)
|
|
+ section = p.getSections("InputClass")[0]
|
|
+ layout = section.get("xkb_layout")
|
|
+ variant = section.get("xkb_variant", "")
|
|
+
|
|
except OSError:
|
|
- doc = piksemel.newDocument("ZORG")
|
|
+ pass
|
|
+
|
|
+ if not layout:
|
|
+ from pardus.localedata import languages
|
|
|
|
- keyboardTag = doc.getTag("Keyboard")
|
|
+ try:
|
|
+ language = file("/etc/mudur/language").read().strip()
|
|
+ except IOError:
|
|
+ language = "en"
|
|
+
|
|
+ if not languages.has_key(language):
|
|
+ language = "en"
|
|
|
|
- if keyboardTag:
|
|
- keyboardTag.hide()
|
|
+ keymap = languages[language].keymaps[0]
|
|
+ layout = keymap.xkb_layout
|
|
+ variant = keymap.xkb_variant
|
|
|
|
- keyboardTag = doc.insertTag("Keyboard")
|
|
- keyboardTag.insertTag("Layout").insertData(layout)
|
|
- if variant:
|
|
- keyboardTag.insertTag("Variant").insertData(variant)
|
|
+ return layout, variant
|
|
|
|
- f = file(consts.config_file, "w")
|
|
- f.write(doc.toPrettyString().replace("\n\n", ""))
|
|
+def saveKeymap(layout, variant=""):
|
|
+ opts = {"layout": layout,
|
|
+ "variant": variant,
|
|
+ "comment_layout": "" if layout else "#",
|
|
+ "comment_variant": "" if variant else "#"}
|
|
+
|
|
+ with open(consts.keymap_conf, "w") as f:
|
|
+ f.write(KEYMAP_CONF_TEMPLATE % opts)
|
|
+ f.flush()
|
|
+ os.fsync(f.fileno())
|
|
Index: zorg-2.0.4/zorg/consts.py
|
|
===================================================================
|
|
--- zorg-2.0.4.orig/zorg/consts.py
|
|
+++ zorg-2.0.4/zorg/consts.py
|
|
@@ -8,6 +8,7 @@ data_dir = "/usr/share/X11"
|
|
modules_dir = "/usr/lib/xorg/modules"
|
|
|
|
xorg_conf_file = "/etc/X11/xorg.conf"
|
|
+keymap_conf = "/etc/X11/xorg.conf.d/00-configured-keymap.conf"
|
|
config_file = join(config_dir, "config.xml")
|
|
configured_bus_file = join(config_dir, "configured_bus")
|
|
drivers_file = join(data_dir, "DriversDB")
|