Fixed the info panel to work well with icons different in size than the
[wmaker-crm.git] / util / wmchlocale.in
blob2dcb3a0eb41b199cf5c41f4451864462628798d2
1 #!/bin/sh
3 # Change locale-dependent settings of WindowMaker.
5 # v0.1 by judas@hell <tomka@oalevice.sk> on Jan 28 2001
9 PROGRAM=`basename $0`
10 VERSION="0.1"
12 if [ "x$GNUSTEP_USER_ROOT" == "x" ]; then
13 GSDIR="$HOME/GNUstep"
14 else
15 GSDIR="$GNUSTEP_USER_ROOT"
16 if [ ! -d "GSDIR" ]; then
17 echo "GNUSTEP_USER_ROOT variable does not contain path to valid directory..." >/dev/stderr
18 exit 1
21 GLOBALDIR="#pkgdatadir#"
22 LOCALDIR="$GSDIR/Library/WindowMaker"
24 help_msg() {
25 echo -e "\n"\
26 "$PROGRAM, v$VERSION by judas@hell\n"\
27 "Syntax:\n"\
28 " $PROGRAM [--auto] [--nodef] [<new-locale> | default]\n"\
29 "\n"\
30 "<new-locale> locale you want WindowMaker to move to (e.g. ja or default)\n"\
31 "--auto use current locale\n"\
32 "--nodef try to change only codings of fonts\n"
33 exit 0
36 if (( $# == 0 )); then
37 help_msg
40 for i in $*; do
41 case $i in
42 --auto)
43 auto="YES";;
44 --nodef)
45 nodef="--nodef";;
47 if [ -z "$new_locale" ]; then
48 new_locale="$i"
49 else
50 echo -e "\nUnrecognized command line argument, run without arguments to see help.\n"
51 exit 1
52 fi;;
53 esac
54 done
55 if [ "$new_locale" == "default" ]; then
56 new_locale=""
59 if [ -n "$auto" ] && [ -z "$new_locale" ]; then
60 new_locale=$LANG
61 if [ -z "$new_locale" ]; then
62 new_locale="${LC_ALL%_*}"
66 if [ -z "$new_locale" ]; then
67 echo -e "\nNo locale is set, using default...\n" >/dev/stderr
68 elif ! (locale -a |grep "^$new_locale$" &>/dev/null); then
69 echo -e "\n"\
70 "Locale $new_locale currently set is not supported on your system...\n"\
71 "Check your LANG and LC_ALL variables or install your locale support\n"\
72 "\n" >/dev/stderr
73 exit 1
76 echo -n "Setting Window Maker root menu... "
78 if [ -z "$new_locale" ] || [ "$new_locale" == "en" ]; then
79 menu_list="plmenu menu"
80 else
81 menu_list="plmenu.$new_locale menu.$new_locale plmenu menu"
83 for new_menu in $menu_list; do
84 for wm_dir in $LOCALDIR $GLOBALDIR; do
85 if [ -f "$wm_dir/$new_menu" ]; then
86 if [ -n "$new_locale" ] && echo "$new_menu" |grep "menu.$new_locale" &>/dev/null; then
87 echo "success"
88 else
89 echo "fail (copying default)"
91 if [ "${new_menu:0:4}" == "menu" ]; then # plain
92 echo "\"$wm_dir/$new_menu\"" >"$GSDIR/Defaults/WMRootMenu"
93 else # proplist
94 cp -f "$wm_dir/$new_menu" "$GSDIR/Defaults/WMRootMenu"
96 any_found="YES"
97 break 2
99 done
100 done
101 if [ -z "$any_found" ]; then
102 echo "fail (no menu found)"
105 echo -n "Setting Window Maker fonts... "
107 if [ -z "$new_locale" ] || [ "$new_locale" == "en" ]; then
108 args="default $nodef"
109 else
110 args="--locale=$new_locale $nodef"
112 if wsetfont "$args" &>/dev/null; then
113 echo "success"
114 else
115 echo -n "fail"
116 if wsetfont default &>/dev/null; then
117 echo " (setting default)"
118 else
119 echo " (totally)"