diff --git a/main/ttyescape/APKBUILD b/main/ttyescape/APKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..b0a57979eb619724e7c13c4e4b99216aa10e4553 --- /dev/null +++ b/main/ttyescape/APKBUILD @@ -0,0 +1,28 @@ +# Maintainer: Caleb Connolly <caleb@connolly.tech> +pkgname=ttyescape +pkgver=0.1 +pkgrel=0 +pkgdesc="Daemon to allow users to escape to a tty" +url="https://postmarketos.org" +arch="all" +license="GPL-3.0-or-later" +depends="triggerhappy fbkeyboard terminus-font kbd" +install="$pkgname.post-install" +source=" + togglevt.sh + ttyescape-thd.conf +" +options="!check" + +package() { + install -Dm755 "$srcdir"/togglevt.sh \ + "$pkgdir"/usr/bin/togglevt.sh + + install -Dm755 "$srcdir"/ttyescape-thd.conf \ + "$pkgdir"/etc/triggerhappy/triggers.d/ttyescape.conf +} + +sha512sums=" +08734715bb62fccd821ed2749145b0ecbdaffbc3b94c439f8ef9c7a2e76acf38c9f6229a58e605f9978e7759c5b1ea877175f8d8a9124eada091711b13b04711 togglevt.sh +3570ce89d3cc493da3aac9f81e2d9072d783d96e43d2194a244096ea1ca3bd76c0ecdb5436531d4ad87c81fa47e95665dfa1a0f7fbded81297c1c950b3184965 ttyescape-thd.conf +" diff --git a/main/ttyescape/togglevt.sh b/main/ttyescape/togglevt.sh new file mode 100644 index 0000000000000000000000000000000000000000..717bb95fb5e3907aac6244cb6231c007d9a9a376 --- /dev/null +++ b/main/ttyescape/togglevt.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Toggle between tty1 and tty2, launching fbkeyboard when on tty2 + +if [ ! -e /dev/uinput ]; then + if ! modprobe -q uinput; then + echo "uinput module not available, please enable it in your kernel" + fi +fi + +currentvt=$(cat /sys/devices/virtual/tty/tty0/active) + +if [ "$currentvt" = "tty2" ]; then + chvt 1 + killall fbkeyboard +else + setfont /usr/share/consolefonts/ter-128n.psf.gz -C /dev/tty2 + chvt 2 + nohup fbkeyboard -r "$(cat /sys/class/graphics/fbcon/rotate)" & +fi diff --git a/main/ttyescape/ttyescape-thd.conf b/main/ttyescape/ttyescape-thd.conf new file mode 100644 index 0000000000000000000000000000000000000000..f8a272ce751e40124aa439b282930b762f708628 --- /dev/null +++ b/main/ttyescape/ttyescape-thd.conf @@ -0,0 +1 @@ +KEY_VOLUMEDOWN+KEY_POWER 1 /usr/bin/togglevt.sh \ No newline at end of file diff --git a/main/ttyescape/ttyescape.post-install b/main/ttyescape/ttyescape.post-install new file mode 100644 index 0000000000000000000000000000000000000000..2c691d0a291653ad59289706c8b8d7fa69570012 --- /dev/null +++ b/main/ttyescape/ttyescape.post-install @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update -q add triggerhappy default \ No newline at end of file