[pykickstart] [PATCH 2/2] Add property generating xorg.conf.d file to the keyboard command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pykickstart/commands/keyboard.py |   57 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/pykickstart/commands/keyboard.py b/pykickstart/commands/keyboard.py
index c5f67bc..0277b87 100644
--- a/pykickstart/commands/keyboard.py
+++ b/pykickstart/commands/keyboard.py
@@ -91,3 +91,60 @@ class F18_Keyboard(FC3_Keyboard):
     @keyboard.setter
     def keyboard(self, value):
         self.layouts_list = [value]
+
+    #code from the pyanaconda.xklavier
+    def _parse_layout_variant(self, layout):
+        """ 
+        Parse layout and variant from the string that may look like 'layout' or
+        'layout (variant)'.
+
+        @return: the (layout, variant) pair, where variant can be ""
+        @rtype: tuple
+
+        """
+
+        variant = ""
+
+        lbracket_idx = layout.find("(")
+        rbracket_idx = layout.rfind(")")
+        if lbracket_idx != -1: 
+            variant = layout[(lbracket_idx + 1) : rbracket_idx]
+            layout = layout[:lbracket_idx].strip()
+
+        return (layout, variant)
+
+    # pylint: disable-msg=E0202
+    @property
+    def xorg_conf(self):
+        layouts = list()
+        variants = list()
+
+        for layout_variant in self.layouts_list:
+            (layout, variant) = self._parse_layout_variant(layout_variant)
+            layouts.append(layout)
+            variants.append(variant)
+
+        #section header
+        ret = 'Section "InputClass"\n'\
+              '\tIdentifier\t"kickstart"\n'\
+              '\tMatchIsKeyboard\t"on"\n'
+
+        #layouts
+        ret += '\tOption\t"XkbLayout"\t'
+        ret += '"' + ','.join(layouts) + '"\n'
+
+        #variants
+        ret += '\tOption\t"XkbVariant"\t'
+        ret += '"' + ','.join(variants) + '"\n'
+
+        #switching
+        #TODO: add option for switching combination
+        #for now, let's default to Alt+Shift
+        ret += '\tOption\t"XkbOptions"\t'
+        ret += '"grp:alt_shift_toggle"\n'
+
+        #section footer
+        ret += 'EndSection'
+
+        return ret
+
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux