aboutsummaryrefslogtreecommitdiff
path: root/init.d/wscons.in
blob: 1f4acf015d40665916998f848186986bcbabfe9c (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!@SBINDIR@/openrc-run
# Copyright (c) 2007-2015 The OpenRC Authors.
# See the Authors file at the top-level directory of this distribution and
# https://github.com/OpenRC/openrc/blob/master/AUTHORS
#
# This file is part of OpenRC. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.

depend()
{
	after clock
	need localmount
	keyword -prefix
}

start()
{
	wscfg=/usr/sbin/wsconscfg
	wsfld=/usr/sbin/wsfontload
	wsctl=/sbin/wsconsctl
	config=/etc/wscons.conf

	# args mean:
	#	screen idx scr emul
	#	font   name width height enc file
	while read type arg1 arg2 arg3 arg4 arg5; do
		case "$type" in
			\#*|"")
				continue
				;;

			font)
				cmd=$wsfld
				[ "$arg2" != "-" ] && cmd="$cmd -w $arg2"
				[ "$arg3" != "-" ] && cmd="$cmd -h $arg3"
				[ "$arg4" != "-" ] && cmd="$cmd -e $arg4"
				cmd="$cmd -N $arg1 $arg5"
				eval "$cmd"
				;;

			screen)
				cmd=$wscfg
				[ "$arg2" != "-" ] && cmd="$cmd -t $arg2"
				[ "$arg3" != "-" ] && cmd="$cmd -e $arg3"
				cmd="$cmd $arg1"
				eval "$cmd"
				;;

			keyboard)
				cmd=$wscfg
				case "$arg1" in
					-|auto)
						cmd="$cmd -k"
						;;
					*)
						cmd="$cmd -k $arg1"
						;;
				esac
				$cmd
				;;

			encoding)
				eval $wsctl -w "\"encoding=$arg1\""
				;;

			mapfile)
				local entry=
				while read entry; do
					case "$entry" in
					\#*|"")
						continue
						;;
					*)
						cmd="$wsctl -w \"map+=$entry\""
						eval "$cmd >/dev/null"
						;;
					esac
				done < "$arg1"
				;;

			mux)
				eval "$wscfg -m $arg1"
				;;

			setvar)
				case "$arg1" in
				keyboard)
					cmd="$wsctl -kw $arg2"
					;;
				display)
					cmd="$wsctl -dw $arg2"
					;;
				mouse)
					cmd="$wsctl -mw $arg2"
					;;
				*)
					cmd="$wsctl -w $arg1"
					;;
				esac
				eval "$cmd"
				;;

		esac
	done < "$config"
}