diff --git a/main/postmarketos-ui-fbkeyboard/APKBUILD b/main/postmarketos-ui-fbkeyboard/APKBUILD new file mode 100644 index 000000000..d72bf4584 --- /dev/null +++ b/main/postmarketos-ui-fbkeyboard/APKBUILD @@ -0,0 +1,18 @@ +# Maintainer: Ferenc Bakonyi +pkgname=postmarketos-ui-fbkeyboard +pkgver=1 +pkgrel=0 +pkgdesc="Plain framebuffer console with touchscreen keyboard support" +url="https://github.com/bakonyiferenc/fbkeyboard" +arch="all" +license="GPL-3.0-or-later" +depends="fbkeyboard coreutils" +install="$pkgname.post-install $pkgname.pre-deinstall $pkgname.post-upgrade" +source="fbkeyboard.init" +options="!check" # No tests + +package() { + install -Dm755 "$srcdir"/fbkeyboard.init "$pkgdir"/etc/init.d/fbkeyboard +} + +sha512sums="386ce9bb48a75a0cbe2dd3617eaa700368d8b3a55d502a15d16415fdebbb3234893a8e0247ff63b6222017c57c1103a0922581311b9d6bbe63b2f7699ea6f15c fbkeyboard.init" diff --git a/main/postmarketos-ui-fbkeyboard/fbkeyboard.init b/main/postmarketos-ui-fbkeyboard/fbkeyboard.init new file mode 100644 index 000000000..edce07254 --- /dev/null +++ b/main/postmarketos-ui-fbkeyboard/fbkeyboard.init @@ -0,0 +1,78 @@ +#!/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 +} diff --git a/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-install b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-install new file mode 100644 index 000000000..aa9f8ae65 --- /dev/null +++ b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-install @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update add fbkeyboard default diff --git a/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-upgrade b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-upgrade new file mode 120000 index 000000000..0f4cc8e6f --- /dev/null +++ b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.post-upgrade @@ -0,0 +1 @@ +postmarketos-ui-fbkeyboard.post-install \ No newline at end of file diff --git a/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.pre-deinstall b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.pre-deinstall new file mode 100644 index 000000000..1e77490d7 --- /dev/null +++ b/main/postmarketos-ui-fbkeyboard/postmarketos-ui-fbkeyboard.pre-deinstall @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update del fbkeyboard