[et-mgmt-tools] [PATCH][RFC] Automatically pick the correct keymap based on the X keymap

Takahashi Tomohiro takatom at jp.fujitsu.com
Mon Mar 26 11:09:26 UTC 2007


Hi,

I made a patch that is automatically pick the correct keymap based
on the X keymap.

The virt-manager gets keymap information from "/etc/sysconfig/keyboard" and
keytable.py
(keytable.py is new python file.)

For example.
=============================
"/etc/sysconfig/keyboard"
KEYBOARDTYPE="pc"
KEYTABLE="jp106"
=============================
If there is KEYTABLE="jp106", it compares "jp106"(/etc/sysconfig/keyboard)
to "jp106"(keytable.py). and it set keymap = "ja". because
"jp106"(keytable.py) is "ja"
Other than those above. if KEYTABLE="us", it set keymap = "en-us".
Because "us"(keytable.py) is "en-us"

If there isn't "/etc/sysconfig/keyboard" or
it cannot open "/etc/sysconfig/keyboard"
The virt-manager doesn't get keymap information (same as before)
and outputs error messeage at virt-manager.log

keytable.py is incomplete file (ex."":"et"). Because I didn't know it.
So, I think that if someone knows it, they support keytable.py

Please give me an advice, if you have it.

Signed-off-by: Tomohiro Takahashi <takatom at jp.fujitsu.com>

Thanks,
Tomohiro Takahashi.

diff -uNrp virt-manager--devel.orig/src/virtManager/create.py
virt-manager--devel/src/virtManager/create.py
--- virt-manager/virt-manager--devel.orig/src/virtManager/create.py
2007-03-26 18:39:05.000000000 +0900
+++ virt-manager--devel/src/virtManager/create.py      2007-03-26
19:21:19.000000000 +0900
@@ -565,7 +565,24 @@ class vmmCreate(gobject.GObject):
             raise ValueError, "Unsupported networking type " + net[0]

         # set up the graphics to use SDL
-        guest.graphics = "vnc"
+        import keytable
+        keymap = None
+        vncport = None
+        try:
+            f = open("/etc/sysconfig/keyboard", "r")
+        except IOError, e:
+            logging.debug('Could not open "/etc/sysconfig/keyboard" ' +
str(e))
+        else:
+            while 1:
+                s = f.readline()
+                if s == "":
+                    break
+                if re.search("KEYTABLE", s) != None:
+                    kt = s.split('"')[1]
+                    if keytable.keytable.has_key(kt):
+                        keymap = keytable.keytable[kt]
+            f.close
+        guest.graphics = (True, "vnc", vncport, keymap)

         logging.debug("Creating a VM " + guest.name + \
                       "\n  Type: " + guest.type + \
diff -uNrp virt-manager--devel.orig/src/virtManager/keytable.py
virt-manager--devel/src/virtManager/keytable.py
--- virt-manager--devel.orig/src/virtManager/keytable.py       1970-01-01
09:00:00.000000000 +0900
+++ virt-manager--devel/src/virtManager/keytable.py    2007-03-26
16:49:06.000000000 +0900
@@ -0,0 +1,37 @@
+# /etc/sysconfig/keyboard:keymap_name_for_qemu-dm
+keytable = {
+    "ar":"ar",
+    "dk":"da",
+    "de":"de",
+    "de-ch":"de-ch",
+    "gb":"en-gb",
+    "us":"en-us",
+    "es":"es",
+    "":"et",
+    "se_FI":"fi",
+    "":"fo",
+    "":"fr",
+    "be":"fr-be",
+    "":"fr-ca",
+    "fr_CH":"fr_ch",
+    "hr":"hr",
+    "":"hu",
+    "":"is",
+    "it":"it",
+    "jp106":"ja",
+    "lt":"lt",
+    "lv":"lv",
+    "mk":"mk",
+    "": "nl",
+    "":"nl-be",
+    "no":"no",
+    "pl":"pl",
+    "pt":"pt",
+    "br":"pt-br",
+    "ru":"ru",
+    "sl":"sl",
+    "":"sv",
+    "th":"th",
+    "tr":"tr",
+    }
+





More information about the et-mgmt-tools mailing list