diff --git a/main/ttyescape/APKBUILD b/main/ttyescape/APKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..a036360b5e90da336e9a3cc51f3190f7cf30f46b --- /dev/null +++ b/main/ttyescape/APKBUILD @@ -0,0 +1,30 @@ +# 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" +makedepends="" +checkdepends="" +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=" +8edd0eedddbe14925a659022af3257b93301a03d112438c9fbe80cee88436777b35a2881ff3f05afb4850b4c25e1f58800b819a76bd5d47cc2dd28304060c3bd togglevt.sh +3570ce89d3cc493da3aac9f81e2d9072d783d96e43d2194a244096ea1ca3bd76c0ecdb5436531d4ad87c81fa47e95665dfa1a0f7fbded81297c1c950b3184965 ttyescape-thd.conf +" diff --git a/main/ttyescape/togglevt.sh b/main/ttyescape/togglevt.sh new file mode 100644 index 0000000000000000000000000000000000000000..1620ddf63f4c8a992beb708d8906f0b923657e96 --- /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" -eq "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