f1ad4128d5
- Make service restart-safe by resetting console size via stop_post() - Check if /dev/uinput exists, and if it does not, do "modprobe -q uinput"
78 lines
1.7 KiB
Text
78 lines
1.7 KiB
Text
#!/sbin/openrc-run
|
|
|
|
name="fbkeyboard"
|
|
command="/usr/bin/fbkeyboard"
|
|
pidfile="/var/run/fbkeyboard.pid"
|
|
command_background=true
|
|
|
|
depend()
|
|
{
|
|
after consolefont
|
|
keyword -docker -lxc -openvz -prefix -systemd-nspawn -uml -vserver -xenu
|
|
}
|
|
|
|
start_pre()
|
|
{
|
|
# Setup kernel support for user level drivers (input subsystem)
|
|
if [ ! -e /dev/uinput ]; then
|
|
if ! modprobe -q uinput; then
|
|
eerror "The uinput module needs to be loaded by " \
|
|
"the fbkeyboard service or built in."
|
|
fi
|
|
fi
|
|
|
|
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
|
|
|
|
if [ "$ttyn" = 0 ]; then
|
|
ebegin "Skipping console setup (rc_tty_number == 0)"
|
|
eend 0
|
|
return 0
|
|
fi
|
|
|
|
local x= rows= retval=0 ttydev=/dev/tty
|
|
|
|
# Set the console size to 2/3, fbkeyboard uses 1/3
|
|
ebegin "Setting console size"
|
|
[ -d /dev/vc ] && ttydev=/dev/vc/
|
|
x=1
|
|
while [ $x -le $ttyn ]; do
|
|
rows=$(stty -F $ttydev$x size | awk '{print $1}')
|
|
rows=$(($rows * 2 / 3))
|
|
if ! stty -F $ttydev$x rows $rows >/dev/null; then
|
|
retval=1
|
|
break
|
|
fi
|
|
: $(( x += 1 ))
|
|
done
|
|
eend $retval
|
|
|
|
return $retval
|
|
}
|
|
|
|
stop_post()
|
|
{
|
|
ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
|
|
|
|
if [ "$ttyn" = 0 ]; then
|
|
ebegin "Skipping console setup (rc_tty_number == 0)"
|
|
eend 0
|
|
return 0
|
|
fi
|
|
|
|
local x= rows= ttydev=/dev/tty
|
|
|
|
# Reset the console size by recalculating the maximum supported rows value
|
|
ebegin "Resetting console size"
|
|
[ -d /dev/vc ] && ttydev=/dev/vc/
|
|
x=1
|
|
while [ $x -le $ttyn ]; do
|
|
rows=$(($(stty -F $ttydev$x size | awk '{print $1}') * 2))
|
|
while stty -F $ttydev$x rows $rows >/dev/null 2>/dev/null ; do
|
|
rows=$(($rows * 2))
|
|
done
|
|
until stty -F $ttydev$x rows $rows >/dev/null 2>/dev/null ; do
|
|
: $((rows--))
|
|
done
|
|
: $(( x += 1 ))
|
|
done
|
|
}
|