]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - setsysfont
daemon: always close stdin, avoids weird program deaths; redirect stdin "in", not...
[projects/rc-scripts.git] / setsysfont
index 403561fc2712611f004f30b1c364f767e421a552..e4f96ab064f0b1485e3c3987e64a89f54ace0b3f 100755 (executable)
@@ -1,18 +1,51 @@
 #!/bin/sh
+#
+#
 
-if [ -f /etc/sysconfig/i18n ]; then
-  . /etc/sysconfig/i18n
+[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
+[ -f /etc/sysconfig/console ] && . /etc/sysconfig/console
+
+[ -n "$SYSFONT" ] && CONSOLEFONT="$SYSFONT"
+
+
+charmap=
+# /usr might not be mounted
+if [ -x /usr/bin/locale ]; then
+       charmap=$(LANG="$LANG" locale charmap)
 fi
 
-if [ -x /usr/bin/consolechars ]; then
-  if [ -n "$SYSFONT" ]; then
-  /usr/bin/consolechars -f $SYSFONT
-  fi
-elif [ -x /usr/bin/setfont ]; then
-  if [ -n "$SYSFONT" ]; then
-    /usr/bin/setfont $SYSFONT
-  fi
-else
-  echo "can't set font"
-  exit 1
+if [ "$charmap" = "UTF-8" ]; then
+       if [ -x /bin/unicode_start ] && /sbin/consoletype fg; then
+               exec unicode_start $CONSOLEFONT $CONSOLEMAP
+       fi
+elif [ -x /bin/unicode_stop ] && /sbin/consoletype fg; then
+       unicode_stop
 fi
+
+# console-tools, obsolete part
+if [ -x /usr/bin/consolechars -o -x /bin/consolechars ]; then
+       if [ -n "$CONSOLEFONT" ]; then
+               consolechars --acm ${CONSOLEMAP:-trivial.trans} --font $CONSOLEFONT
+       fi
+       if [ -n "$KEYTABLE" ]; then
+               loadkeys $KEYTABLE < /dev/tty0 > /dev/tty0
+       fi
+# kbd, currently used
+elif [ -x /usr/bin/setfont -o -x /bin/setfont ]; then
+       if [ -n "$CONSOLESCREENFONTMAP" ]; then
+               ARGS="-u $CONSOLESCREENFONTMAP"
+       fi
+       if [ -n "$CONSOLEMAP" ]; then
+               if [ ! -f /lib/kbd/consoletrans/${CONSOLEMAP}_to_uni.trans ]; then
+                       CONSOLEMAP=$(echo "$CONSOLEMAP" | awk '{ gsub(/iso[0]?/,"8859-"); print $0; }')
+               fi
+               ARGS="$ARGS -m $CONSOLEMAP"
+       fi
+       if [ -n "$CONSOLEFONT" ]; then
+               setfont $CONSOLEFONT $ARGS
+       else
+               echo -ne "\033(K" 2>/dev/null > /proc/$$/fd/0
+       fi
+fi
+
+exit 0
This page took 0.062967 seconds and 4 git commands to generate.