home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/bin/sh #change locale #locale files are in /usr/lib/locale/ but Puppy won't have all of them. #they are from glibc package I think. So, will make them into an Unleashed pkg #and this script can download it, but not install it, just pick out the required #locale. ...god no, the directory in Vector is 43.8M. So will grab a selection. CURRENTLOCALE="`cat /etc/profile | grep "LANG=" | cut -f 2 -d '=' | cut -f 1 -d ' ' | cut -f 1`" INSTALLEDLOCALES="`ls -1 /usr/lib/locale`" INSTALLEDLOCSP="`echo -n "$INSTALLEDLOCALES" | tr "\n" " "`" if [ "$INSTALLEDLOCALES" ];then xmessage -bg "#ffc0c0" -center -name "chooselocale" -title "chooselocale: Choose source" -buttons "LOCAL:10,DOWNLOAD:11,EXIT:12" "Welcome to the Puppy locale chooser! This will set the language and localisations for your region. Puppy is an English-only distro, however there are various internationalisation projects in progress, and this little locale switcher program is my contribution. To save space Puppy has only these locales installed locally: $INSTALLEDLOCSP And Puppy is currently set to this locale: $CURRENTLOCALE Click on LOCAL button if you want to choose from the above only... Click DOWNLOAD button if you want to download more locales to choose from..." case $? in 10) LOCSRC="local" ;; 11) LOCSRC="download" ;; *) exit ;; esac fi if [ "$LOCSRC" = "download" ];then while [ 1 ];do WWWSITE="" PKGSRC="ftp://ibiblio.org/pub/Linux/distributions/puppylinux/pupget_packages-1" ping -c 1 -q ibiblio.org if [ ! $? -eq 0 ];then ping -c 1 -q ftp.nluug.nl if [ $? -eq 0 ];then WWWSITE="ftp.nluug.nl" PKGSRC="http://ftp.nluug.nl/ftp/pub/os/Linux/distr/puppylinux/pupget_packages-1" fi else WWWSITE="ibiblio.org" fi if [ ! "$WWWSITE" ];then xmessage -bg "#ff8080" -center -name "chooselocale" -title "chooselocale: NO INTERNET" -buttons "OKAY:10,EXIT:11" "Sorry, but there does not appear to be a connection to the Internet. This program needs to download locale files off the Internet. Connect to the Internet then click the OKAY button..." if [ ! $? -eq 10 ];then exit fi else break fi done fi if [ "$LOCSRC" = "download" ];then #get name of locales pkg... #v2.0.0 unleashedpackages.txt no longer used, now use packages.txt here... APKGNAME="`cat /root/.packages/packages.txt | grep '"glibc_locales-' | head -n 1 | cut -f 2 -d '"'`" if [ ! "$APKGNAME" ];then exit fi #download locales pkg... xmessage -bg "orange" -center -name "chooselocale" -title "chooselocale: downloading locales" -buttons "" "Downloading locale files from $WWWSITE, please wait..." & mkdir /root/tmp 2> /dev/null cd /root/tmp while [ 1 ];do rxvt -name pupget -bg orange -geometry 80x10 -e wget $PKGSRC/${APKGNAME}.tar.gz sync tar -zxf $APKGNAME.tar.gz if [ $? -eq 0 ];then break fi rm -f $APKGNAME.tar.gz 2> /dev/null done killall xmessage fi #create list of locales in format for display in Xdialog radiolist... if [ "$LOCSRC" = "download" ];then LOCALENAMES="`ls -1 /root/tmp/$APKGNAME/usr/lib/locale | tr "\n" " "`" else LOCALENAMES="`ls -1 /usr/lib/locale | tr "\n" " "`" fi echo -n "" > /tmp/taglocales.txt for ONELOCALE in $LOCALENAMES do if [ "$ONELOCALE" = "$CURRENTLOCALE" ];then FSTATUS="on" else FSTATUS="off" fi echo " \"$ONELOCALE\" \"$ONELOCALE\" $FSTATUS \\" >> /tmp/taglocales.txt done sync TAGLOCALES="`cat /tmp/taglocales.txt`" CURRENTWM="`cat /etc/windowmanager`" rm -f /tmp/rettag.txt 2> /dev/null echo '#!/bin/sh' > /tmp/pkgdialog echo 'RETTAG="`Xdialog --title "chooselocale: Choose a locale" --left --stdout --no-tags --radiolist "Please choose a locale.\nX will be restarted after click OKAY button\n\nNote that the chosen locale files will be saved in /usr/lib/locale\nand the LANG environment variable will be set in /etc/profile" 0 0 10 \' >> /tmp/pkgdialog echo "$TAGLOCALES" >> /tmp/pkgdialog echo ' `"' >> /tmp/pkgdialog echo 'if [ ! $? -eq 0 ];then' >> /tmp/pkgdialog echo ' exit' >> /tmp/pkgdialog echo 'fi' >> /tmp/pkgdialog echo 'echo -n "$RETTAG" > /tmp/rettag.txt' >> /tmp/pkgdialog # ' #dummy tick to fix highlighting sync chmod 755 /tmp/pkgdialog /tmp/pkgdialog if [ ! -f /tmp/rettag.txt ];then exit fi #copy chosen locale into Puppy... NEWLOCALE="`cat /tmp/rettag.txt`" if [ "$LOCSRC" = "download" ];then #rm -rf /usr/lib/locale/$NEWLOCALE 2> /dev/null cp -a --remove-destination /root/tmp/$APKGNAME/usr/lib/locale/$NEWLOCALE /usr/lib/locale/ sync rm -rf /root/tmp/$APKGNAME rm -f /root/tmp/$APKGNAME.* fi if [ ! -d /usr/lib/locale/$NEWLOCALE ];then xmessage "ERROR occurred. Quiting..." exit fi #warning before restart X... xmessage -bg "#c0ffc0" -center -name "chooselocale" -title "chooselocale: Success" -buttons "OKAY:10,EXIT:11" "It seems okay so far! Your chosen new locale is $NEWLOCALE. The new locale files are in place in /usr/lib/locale. The LANG environment variable will be changed in /etc/profile when you click the OKAY button, then X will be restarted. The X graphics server now has to be restarted for the change to take effect. This script will rudely terminate all X apps, so it would be wise to close any open windows and running applications yourself, right now, before clicking the OKAY button. Note, if the new locale does not work, the files for the old locale ($CURRENTLOCALE) should still be in /usr/lib/locale, and you can manually edit the LANG variable in /etc/profile to change back. NOTE: For those interested in exactly how this switching works, as well as restarting X the new LANG has to be enabled and this is done in /usr/X11R6/bin/xwin -- look near the bottom of the script. Click OKAY button to restart X... Click EXIT button to quit without changing locale..." if [ $? -eq 10 ];then #Change locale and restart X... OLDLANG="LANG=$CURRENTLOCALE" NEWLANG="LANG=$NEWLOCALE" cat /etc/profile | sed -e "s/${OLDLANG}/${NEWLANG}/" > /tmp/profile sync cp -f /tmp/profile /etc/profile rm -rf /tmp/.X0-lock #killall -9 X sync exec restartwm $CURRENTWM fi ###END###