summaryrefslogtreecommitdiffstats
path: root/abs/core/linhes-live/bin/km
blob: 386d966d4e17a7f90f8e0de5ef26f92ce4d09c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# $Id: km,v 1.2 2005/12/13 04:14:53 judd Exp $
# Modified by gradgrind to deal only with i386 keymaps
#     and BASEDIR changed
#  - also saves results to /etc/rc.conf

# test if the script is started by root user. If not, exit
if [ $UID -ne 0 ]; then
    echo "This should be run as root"; exit 1
fi

ANSWER="/tmp/.km"
BASEDIR="/usr/share/kbd"

domenu()
{
	menutype=$1 ; shift
	text=$1     ; shift
	height=$1   ; shift
	width=$1    ; shift
	mheight=$1  ; shift
	
	dialog --cancel-label "Skip" --$menutype "$text" $height $width $mheight $*
}

if [ ! -d $BASEDIR/keymaps ]; then
	echo "Cannot load keymaps, as none were found in $BASEDIR/keymaps" >&2
	exit 1
else
	echo "Scanning for keymaps..."
	KEYMAPS=
	for t in qwerty qwertz azerty dvorak; do
	    for i in `find $BASEDIR/keymaps/i386/$t -follow -name "*.gz"`; do
		fn=`echo $i | sed "s|$BASEDIR/keymaps/i386/||"`
		KEYMAPS="$KEYMAPS $fn -"
	    done
	done
	domenu menu "Select A Keymap" 22 60 16 $KEYMAPS 2>$ANSWER
	keymap=`cat $ANSWER`
fi

if [ ! -d $BASEDIR/consolefonts ]; then
	echo "Cannot load consolefonts, as none were found in $BASEDIR/consolefonts" >&2
else
	echo "Scanning for fonts..."
	FONTS=
	for i in `find $BASEDIR/consolefonts -follow -name "*.gz"`; do
		fn=`echo $i | sed "s|$BASEDIR/consolefonts/||"`
		FONTS="$FONTS $fn -"
	done
	domenu menu "Select A Console Font" 22 60 16 $FONTS 2>$ANSWER
	font=`cat $ANSWER`
fi

if [ "$keymap" ]; then
	echo "Loading keymap: $keymap"
	loadkeys -q $BASEDIR/keymaps/i386/$keymap
	sed -i "s|^KEYMAP=.*|KEYMAP=\"$( echo $keymap | \
	       cut -d'.' -f1 )\"|" /etc/rc.conf
fi

if [ "$font" ]; then
	echo "Loading font: $font"
	for i in `seq 1 4`; do
		if [ -d /dev/vc ]; then
			setfont $BASEDIR/consolefonts/$font -C /dev/vc/${i}
		else
			setfont $BASEDIR/consolefonts/$font -C /dev/tty${i}
		fi
	done
	sed -i "s|^CONSOLEFONT=.*|CONSOLEFONT=\"$( echo $font | \
	       cut -d'.' -f1 )\"|" /etc/rc.conf
fi

exit 0