Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=f24698ba9996fb1267b35bb7f7185a105a340834

commit f24698ba9996fb1267b35bb7f7185a105a340834
Author: bouleetbil <[email protected]>
Date:   Wed Jan 11 13:57:11 2012 +0100

fw-lang
*update keymap,10-evdev.conf,lang.sh
*should find a good default keymap for the other lang

diff --git a/frugal-tweak-python/fw-lang/fw-lang.py 
b/frugal-tweak-python/fw-lang/fw-lang.py
index 322f579..b2da80f 100644
--- a/frugal-tweak-python/fw-lang/fw-lang.py
+++ b/frugal-tweak-python/fw-lang/fw-lang.py
@@ -22,44 +22,97 @@
# * THE SOFTWARE.
# */

-import sys
-import os
-import curses
+import sys,os

ConfigKeymap = "/etc/sysconfig/keymap"
-ConfigLanguage = "/etc/sysconfig/language"
ConfigLang = "/etc/profile.d/lang.sh"
-win=None
+#ConfigLang = "lang.sh"
+#ConfigKeymap = "keymap"

-def curses_init():
-       #init ncurses
-       curses.initscr()
-       curses.noecho()
-       curses.cbreak()
-       stdscr.keypad(1)
-
-def curses_finally():
-       curses.nocbreak()
-       stdscr.keypad(0)
-       curses.echo()
-       curses.endwin()
-
-def create_window():
-       begin_x = 20 ; begin_y = 7
-       height = 5 ; width = 40
-       global win
-       win = curses.newwin(height, width, begin_y, begin_x)
-
-def refresh_window():
-       win.refresh()
-
-def main():
-       curses_init()
-       curses_finally()
-       return 0
-
-if __name__ == "__main__":
-    main()
+def replace(section,value,configfile):
+       if os.path.exists(configfile)==1:
+               import codecs
+               file = codecs.open(configfile,"r","utf-8")
+               text=""
+               for line in file:
+                       if line.find(section)==0:
+                               line=value+"\n"
+                       text=text+line
+               FILE = open(configfile,"w")
+               FILE.writelines(text)


+def print_menu():
+       print ("language...")
+       print ("1. pt_BR - Brazilian Portuguese")
+       print ("2. cz_CZ - Czech")
+       print ("3. da_NK - Danish")
+       print ("4. nl_NL - Dutch")
+       print ("5. en_US - English")
+       print ("6. fr_FR - French")
+       print ("7. de_DE - German")
+       print ("8. hu_HU - Hungarian")
+       print ("9. id_ID - Indonesian")
+       print ("10. it_IT - Italian")
+       print ("11. ro_RO - Romanian")
+       print ("12. sk_SK - Slovak")
+       print ("13. sv_SE - Swedish")
+       x = input("Select your language: ")
+       if x == 1:
+               replace("export LANG","export LANG=pt_BR",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 2:
+               replace("export LANG","export LANG=cz_CZ",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 3:
+               replace("export LANG","export LANG=da_NK",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 4:
+               replace("export LANG","export LANG=nl_NL",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 5:
+               replace("export LANG","export LANG=en_US",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 6:
+               replace("export LANG","export LANG=fr_FR",ConfigLang)
+               replace("keymap=","keymap=fr-latin9",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 7:
+               replace("export LANG","export LANG=de_DE",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 8:
+               replace("export LANG","export LANG=hu_HU",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 9:
+               replace("export LANG","export LANG=id_ID",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 10:
+               replace("export LANG","export LANG=it_IT",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 11:
+               replace("export LANG","export LANG=ro_RO",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 12:
+               replace("export LANG","export LANG=sk_SK",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       elif x == 13:
+               replace("export LANG","export LANG=sv_SE",ConfigLang)
+               replace("keymap=","keymap=",ConfigKeymap)
+               os.system("updatexorg.sh")
+       else:
+               print x
+               print_menu()
+print_menu()

+sys.exit()
diff --git a/frugal-tweak-python/fw-lang/updatexorg.sh 
b/frugal-tweak-python/fw-lang/updatexorg.sh
new file mode 100644
index 0000000..608d4ce
--- /dev/null
+++ b/frugal-tweak-python/fw-lang/updatexorg.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#/*
+# * Copyright (c) 2010 gaetan gourdin
+# *
+# * Permission is hereby granted, free of charge, to any person obtaining a 
copy
+# * of this software and associated documentation files (the "Software"), to 
deal
+# * in the Software without restriction, including without limitation the 
rights
+# * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# * copies of the Software, and to permit persons to whom the Software is
+# * furnished to do so, subject to the following conditions:
+# *
+# * The above copyright notice and this permission notice shall be included in
+# * all copies or substantial portions of the Software.
+# *
+# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+# * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# * THE SOFTWARE.
+# */
+
+layout="us"
+Findxkb="0"
+if [ -e /etc/sysconfig/keymap ]; then
+       # setting the layout from the tty console layout created by the 
installer
+       layout=`awk -F'=' '/^keymap=/ {print $2}' /etc/sysconfig/keymap | sed 
's|-.*||g'`
+       #if we should fix some others layout
+       #FS#4353
+       case "$layout" in
+               "uk") layout=gb  ;;
+               "sv") layout=se  ;;
+               "cf") layout=ca  ;;
+               "fr_CH") layout=ch  ;;
+               "la") layout=latam ;;
+       esac
+fi
+
+filexkb="/usr/share/X11/xkb/rules/xorg.lst"
+canread="0"
+while read linexkb
+do
+       if [ "$linexkb" == "! variant" ] ; then
+               break
+               #layout finish read variant
+       fi
+       if [ "$linexkb" == "! layout" ] ; then
+               #begin to define layout now we can read file
+               canread="1";
+       fi
+       if [ "$canread" == "1" ] ; then
+               lineLayout=`echo $linexkb |cut -d ' ' -f1`
+               if [ "$lineLayout" == "$layout" ] ; then
+                       Findxkb="1"
+                       echo "Find correct layout xkb : $layout"
+                       break
+               fi
+       fi
+done < $filexkb
+if [ "$Findxkb" == "0" ] ; then
+       layout="us"
+       echo "Xorg will use layout us"
+       echo "You can edit /etc/X11/xorg.conf.d/10-evdev.conf for change it"
+fi
+echo "Update layout keyboard with $layout"
+sed -i "/XkbLayout/s/Keyboard_Layout/$layout/" 
/etc/X11/xorg.conf.d/10-evdev.conf
+
+
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to