RIP PCVT userland.
[dragonfly.git] / etc / rc.d / pcvt
1 #!/bin/sh -
2 #
3 # Copyright (c) 2002  The FreeBSD Project
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD: src/etc/rc.d/pcvt,v 1.3 2002/10/12 10:31:31 schweikh Exp $
28 # $DragonFly: src/etc/rc.d/Attic/pcvt,v 1.2 2004/01/27 00:42:45 rob Exp $
29 #
30
31 # PROVIDE: pcvt
32 # REQUIRE: LOGIN
33 # KEYWORD: DragonFly
34
35 . /etc/rc.subr
36
37 name="pcvt"
38 start_precmd="pcvt_precmd"
39 start_cmd="pcvt_start"
40
41 pcvt_precmd()
42 {
43         if [ -x /usr/sbin/ispcvt ]; then
44                 /usr/sbin/ispcvt -d /dev/ttyv0 && return 0
45         fi
46         return 1
47 }
48
49 pcvt_echo()
50 {
51         if checkyesno pcvt_verbose; then
52                 echo $1 "$2"
53         fi
54 }
55
56 pcvt_start()
57 {
58         # path for pcvt's EGA/VGA download fonts
59         FONTP=/usr/share/misc/pcvtfonts
60
61         if checkyesno pcvt_verbose; then
62                 echo "Configuring pcvt console driver:"
63         else
64                 echo "-n" "Configuring pcvt"
65         fi
66
67         # video adapter type
68
69         adapter=`/usr/sbin/scon -d /dev/ttyv0 -a`
70
71         pcvt_echo "-n" "  video adapter type is $adapter, "
72
73         # monitor type (mono/color)
74
75         monitor=`/usr/sbin/scon -d /dev/ttyv0 -m`
76
77         pcvt_echo "" "monitor type is $monitor"
78
79         # load fonts into VGA
80
81         if [ $adapter = VGA ]; then
82                 pcvt_echo "-n" "  loading fonts: 8x16:0,"
83                 loadfont -d /dev/ttyv0 -c0 -f $FONTP/vt220l.816
84
85                 pcvt_echo "-n" "1 "
86                 loadfont -d /dev/ttyv0 -c1 -f $FONTP/vt220h.816
87
88                 pcvt_echo "-n" " 8x14:0,"
89                 loadfont -d /dev/ttyv0 -c2 -f $FONTP/vt220l.814
90
91                 pcvt_echo "-n" "1 "
92                 loadfont -d /dev/ttyv0 -c3 -f $FONTP/vt220h.814
93
94                 pcvt_echo "-n" " 8x10:0,"
95                 loadfont -d /dev/ttyv0 -c4 -f $FONTP/vt220l.810
96
97                 pcvt_echo "-n" "1 "
98                 loadfont -d /dev/ttyv0 -c5 -f $FONTP/vt220h.810
99
100                 pcvt_echo "-n" " 8x8:0,"
101                 loadfont -d /dev/ttyv0 -c6 -f $FONTP/vt220l.808
102
103                 pcvt_echo "" "1 "
104                 loadfont -d /dev/ttyv0 -c7 -f $FONTP/vt220h.808
105
106         # setting screen sizes
107
108                 case ${pcvt_lines} in
109                 28)
110                         size=-s28
111                         pcvt_echo "" "  switching to 28 lines"
112                         ;;
113                 40)
114                         size=-s40
115                         pcvt_echo "" "  switching to 40 lines"
116                         ;;
117                 50)
118                         size=-s50
119                         pcvt_echo "" "  switching to 50 lines"
120                         ;;
121                 *)
122                         size=-s25
123                         pcvt_echo "" "  switching to 25 lines"
124                         ;;
125                 esac
126         fi
127
128         # use HP extensions to VT220 or plain VT220 ?
129
130         if checkyesno pcvt_hpext; then
131                 emulation=-H
132                 pcvt_echo "" "  setting emulation to VT220 with HP extensions"
133         else
134                 emulation=-V
135                 pcvt_echo "" "  setting emulation to VT220"
136         fi
137
138         # for all screens do
139
140         for device in /dev/ttyv*
141         do
142                 # set emulation
143
144                 /usr/sbin/scon -d$device $size $emulation >/dev/null 2>&1
145                 if [ $? != 0 ]; then
146                         break 1
147                 fi
148
149                 # set cursor shape
150
151                 case ${pcvt_cursorh} in
152                 [Nn][Oo] | '')
153                         ;;
154                 *)
155                         case ${pcvt_cursorl} in
156                         [Nn][Oo] | '')
157                                 ;;
158                         *)
159                                 /usr/sbin/cursor -d$device -s$pcvt_cursorh -e$pcvt_cursorl
160                                 ;;
161                         esac
162                         ;;
163                 esac
164
165                 # on monochrome monitor, set color palette to use a higher intensity
166
167                 if checkyesno pcvt_monohigh && \
168                         [ $monitor = MONO -a $adapter = VGA ]
169                 then
170                         /usr/sbin/scon -d$device -p8,60,60,60
171                 fi
172         done
173
174         # switch to screen 0
175
176         pcvt_echo "" "  switching to screen 0"
177
178         /usr/sbin/scon -d /dev/ttyv0
179
180         # screensaver timeout
181
182         case ${pcvt_blanktime} in
183         [Nn][Oo] | '')
184                 ;;
185         *)
186                 pcvt_echo "" "  setting screensaver timeout to $pcvt_blanktime seconds"
187                 /usr/sbin/scon -d /dev/ttyv0 -t$pcvt_blanktime
188                 ;;
189         esac
190
191         # national keyboard layout
192
193         case ${pcvt_keymap} in
194         [Nn][Oo] | '')
195                 ;;
196         *)
197                 pcvt_echo "" "  switching national keyboard layout to $pcvt_keymap"
198                 /usr/sbin/kcon -m $pcvt_keymap
199                 ;;
200         esac
201
202         # keyboard repeat delay value
203
204         case ${pcvt_keydel} in
205         [Nn][Oo] | '')
206                 ;;
207         *)
208                 pcvt_echo "" "  setting keyboard delay to $pcvt_keydel"
209                 /usr/sbin/kcon -d$pcvt_keydel
210                 ;;
211         esac
212
213         # keyboard repeat rate value
214
215         case ${pcvt_keyrate} in
216         [Nn][Oo] | '')
217                 ;;
218         *)
219                 pcvt_echo "" "  setting keyboard repeat rate to $pcvt_keyrate"
220                 /usr/sbin/kcon -r$pcvt_keyrate
221                 ;;
222         esac
223
224         # done
225
226         if checkyesno pcvt_verbose; then
227                 echo "Finished configuring pcvt console driver."
228         else
229                 echo "."
230         fi
231 }
232
233 load_rc_config $name
234 run_rc_command "$1"