Home | History | Annotate | Line # | Download | only in rc.d
wscons revision 1.13.56.1
      1        1.1     lukem #!/bin/sh
      2        1.1     lukem #
      3  1.13.56.1  perseant # $NetBSD: wscons,v 1.13.56.1 2025/08/02 05:20:45 perseant Exp $
      4        1.1     lukem #
      5        1.1     lukem 
      6        1.1     lukem # PROVIDE: wscons
      7        1.4     lukem # REQUIRE: mountcritremote
      8        1.8   thorpej # BEFORE:  LOGIN
      9        1.1     lukem 
     10       1.10   mycroft $_rc_subr_loaded . /etc/rc.subr
     11        1.1     lukem 
     12        1.1     lukem name="wscons"
     13        1.6     lukem rcvar=$name
     14        1.5     lukem start_cmd="wscons_start"
     15        1.2     veego stop_cmd=":"
     16        1.1     lukem 
     17        1.5     lukem wscons_start()
     18        1.1     lukem {
     19        1.5     lukem 	wscfg=/usr/sbin/wsconscfg
     20        1.5     lukem 	wsfld=/usr/sbin/wsfontload
     21        1.7  drochner 	wsctl=/sbin/wsconsctl
     22        1.5     lukem 	config=/etc/wscons.conf
     23        1.5     lukem 	usage="Usage: wsconfig [-n] [-f configfile] [-font fontpgm] [-screen screenpgm]"
     24        1.5     lukem 	DOIT=
     25        1.5     lukem 
     26        1.5     lukem 	while [ $# -gt 0 ]; do
     27        1.5     lukem 		case $1 in
     28        1.5     lukem 			-n)
     29        1.5     lukem 				DOIT=echo
     30        1.5     lukem 				;;
     31        1.5     lukem 			-f)
     32        1.5     lukem 				config=$2
     33        1.5     lukem 				shift
     34        1.5     lukem 				;;
     35        1.5     lukem 			-font)
     36        1.5     lukem 				wsfld=$2
     37        1.5     lukem 				shift
     38        1.5     lukem 				;;
     39        1.5     lukem 			-screen)
     40        1.5     lukem 				wscfg=$2
     41        1.5     lukem 				shift
     42        1.5     lukem 				;;
     43        1.5     lukem 			*)
     44        1.5     lukem 				echo $usage
     45        1.5     lukem 				exit 1
     46        1.5     lukem 				;;
     47        1.5     lukem 		esac
     48        1.5     lukem 		shift
     49        1.5     lukem 	done
     50        1.5     lukem 
     51        1.5     lukem 
     52        1.5     lukem 	# args mean:
     53        1.5     lukem 	#	screen idx scr emul
     54        1.5     lukem 	#	font   name width height enc file
     55        1.5     lukem 	( while read type arg1 arg2 arg3 arg4 arg5; do
     56        1.5     lukem 		case "$type" in
     57        1.5     lukem 			\#*|"")
     58        1.5     lukem 				continue
     59        1.5     lukem 				;;
     60        1.9     lukem 
     61        1.5     lukem 			font)
     62        1.5     lukem 				name=$arg1
     63        1.5     lukem 				width=$arg2
     64        1.5     lukem 				height=$arg3
     65        1.5     lukem 				enc=$arg4
     66        1.5     lukem 				file=$arg5
     67        1.5     lukem 				cmd=$wsfld
     68        1.5     lukem 
     69        1.5     lukem 				case $width in
     70        1.5     lukem 					-)
     71        1.5     lukem 						;;
     72        1.5     lukem 					*)
     73        1.5     lukem 						cmd="$cmd -w $width"
     74        1.5     lukem 						;;
     75        1.5     lukem 				esac
     76        1.5     lukem 				case $height in
     77        1.5     lukem 					-)
     78        1.5     lukem 						;;
     79        1.5     lukem 					*)
     80        1.5     lukem 						cmd="$cmd -h $height"
     81        1.5     lukem 						;;
     82        1.5     lukem 				esac
     83        1.5     lukem 				case $enc in
     84        1.5     lukem 					-)
     85        1.5     lukem 						;;
     86        1.5     lukem 					*)
     87        1.5     lukem 						cmd="$cmd -e $enc"
     88        1.5     lukem 						;;
     89        1.5     lukem 				esac
     90        1.5     lukem 				cmd="$cmd -N $name $file"
     91        1.5     lukem 				eval $DOIT $cmd
     92        1.5     lukem 				;;
     93        1.9     lukem 
     94        1.5     lukem 			screen)
     95        1.5     lukem 				idx=$arg1
     96        1.5     lukem 				scr=$arg2
     97        1.5     lukem 				emul=$arg3
     98        1.5     lukem 				cmd=$wscfg
     99        1.5     lukem 
    100        1.5     lukem 				case $scr in
    101        1.5     lukem 					-)
    102        1.5     lukem 						;;
    103        1.5     lukem 					*)
    104        1.5     lukem 						cmd="$cmd -t $scr"
    105        1.5     lukem 						;;
    106        1.5     lukem 				esac
    107        1.5     lukem 				case $emul in
    108        1.5     lukem 					-)
    109        1.5     lukem 						;;
    110        1.5     lukem 					*)
    111        1.5     lukem 						cmd="$cmd -e $emul"
    112        1.5     lukem 						;;
    113        1.5     lukem 				esac
    114        1.5     lukem 				cmd="$cmd $idx"
    115        1.5     lukem 				eval $DOIT $cmd
    116        1.5     lukem 				;;
    117        1.9     lukem 
    118        1.5     lukem 			keyboard)
    119        1.5     lukem 				kbd=$arg1
    120        1.5     lukem 				cmd=$wscfg
    121        1.5     lukem 				case $kbd in
    122        1.5     lukem 					-|auto)
    123        1.5     lukem 						cmd="$cmd -k"
    124        1.5     lukem 						;;
    125        1.5     lukem 					*)
    126        1.5     lukem 						cmd="$cmd -k $kbd"
    127        1.5     lukem 						;;
    128        1.5     lukem 				esac
    129        1.5     lukem 				eval $DOIT $cmd
    130        1.7  drochner 				;;
    131        1.9     lukem 
    132        1.7  drochner 			encoding)
    133        1.7  drochner 				map=$arg1
    134        1.9     lukem 				cmd="$wsctl -w \"encoding=$map\""
    135       1.13   mbalmer 				echo -n 'Keyboard '
    136        1.7  drochner 				eval $DOIT $cmd
    137        1.7  drochner 				;;
    138        1.9     lukem 
    139        1.7  drochner 			mapfile)
    140        1.7  drochner 				mapfile=$arg1
    141        1.7  drochner 				( while read entry; do
    142        1.7  drochner 				    case "$entry" in
    143        1.7  drochner 					\#*|"")
    144        1.7  drochner 					    continue
    145        1.7  drochner 					    ;;
    146        1.7  drochner 					*)
    147        1.9     lukem 					    cmd="$wsctl -w \"map+=$entry\""
    148        1.7  drochner 					    cmd="$cmd >/dev/null"
    149        1.7  drochner 					    eval $DOIT $cmd
    150        1.7  drochner 					    ;;
    151        1.7  drochner 				    esac
    152        1.7  drochner 				done ) < $mapfile
    153        1.5     lukem 				;;
    154        1.9     lukem 
    155        1.5     lukem 			mux)
    156        1.5     lukem 				cmd="$wscfg -m $arg1"
    157        1.5     lukem 				eval $DOIT $cmd
    158        1.5     lukem 				;;
    159        1.9     lukem 
    160        1.9     lukem 			setvar)
    161       1.12    mishka 				dev=$arg1
    162       1.12    mishka 				var=$arg2
    163       1.12    mishka 				val=$arg3
    164       1.12    mishka 
    165       1.12    mishka 				case $dev in
    166  1.13.56.1  perseant 				    ttyE*|constty|console)
    167       1.12    mishka 					cmdmod="-d"
    168       1.11     peter 					;;
    169       1.12    mishka 				    wskbd*)
    170       1.12    mishka 					cmdmod="-k"
    171       1.11     peter 					;;
    172       1.12    mishka 				    wsmouse*)
    173       1.12    mishka 					cmdmod="-m"
    174       1.11     peter 					;;
    175       1.11     peter 				esac
    176       1.12    mishka 				echo -n "$dev: "
    177       1.12    mishka 				cmd="$wsctl -f /dev/$dev $cmdmod -w $var=$val"
    178        1.9     lukem 				eval $DOIT $cmd
    179        1.9     lukem 				;;
    180        1.9     lukem 
    181        1.5     lukem 		esac
    182        1.5     lukem 	done ) < $config
    183        1.1     lukem }
    184        1.1     lukem 
    185        1.3     lukem load_rc_config $name
    186        1.1     lukem run_rc_command "$1"
    187