main/ttyescape: move to own repo (MR 3017)
This commit is contained in:
parent
6ec43fbbb4
commit
be91c62136
@ -1,26 +1,25 @@
|
||||
# Maintainer: Caleb Connolly <caleb@connolly.tech>
|
||||
pkgname=ttyescape
|
||||
pkgver=0.2
|
||||
pkgver=1.0.1
|
||||
pkgrel=0
|
||||
pkgdesc="Daemon to allow users to escape to a tty"
|
||||
url="https://postmarketos.org"
|
||||
url="https://gitlab.com/postmarketOS/ttyescape"
|
||||
arch="noarch"
|
||||
license="GPL-3.0-or-later"
|
||||
depends="hkdm buffyboard terminus-font kbd"
|
||||
install="$pkgname.post-install"
|
||||
subpackages="$pkgname-openrc"
|
||||
source="
|
||||
togglevt.sh
|
||||
ttyescape-hkdm.toml
|
||||
https://gitlab.com/postmarketOS/ttyescape/-/archive/$pkgver/ttyescape-$pkgver.tar.gz
|
||||
etc-conf-d-ttyescape.conf
|
||||
"
|
||||
options="!check"
|
||||
|
||||
package() {
|
||||
install -Dm755 "$srcdir"/togglevt.sh \
|
||||
install -Dm755 "$builddir"/togglevt.sh \
|
||||
"$pkgdir"/usr/bin/togglevt.sh
|
||||
|
||||
install -Dm755 "$srcdir"/ttyescape-hkdm.toml \
|
||||
install -Dm755 "$builddir"/ttyescape-hkdm.toml \
|
||||
"$pkgdir"/etc/hkdm/config.d/ttyescape.toml
|
||||
|
||||
install -Dm755 "$srcdir"/etc-conf-d-ttyescape.conf \
|
||||
@ -28,7 +27,6 @@ package() {
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
d7447788044b76862688f4fbd722725a787f8fe07ef1d8fde34f01591e680dd782fd4085fd80166a695e0016162d4a8701e749ae4a56a9cf8ae388ab43ef72e1 togglevt.sh
|
||||
88034b54b06a962ff353a7a5a272352b56fdb564231a13be85b73d9dfc991d1ec8085014ebfcd5c6eaee67e62341dd2c9c7ace91a2c839702ae3b7f6007433f4 ttyescape-hkdm.toml
|
||||
b196cad01d490ac759fc72d58382ffe621b1f33f2ec9794a7937b41bfb9a0f200939d20cd027a2c48d44d095cd8570f332c995ab015d459387d63c7788fd8298 ttyescape-1.0.1.tar.gz
|
||||
ac06c2ae2b3b8404d6ed79a046b175abbeb2360033edcaa22c21e1a61c68913e58013e9200ee5b786eee9020a2c78d1bda09c72d87ea0998bf6eeb71da015a2f etc-conf-d-ttyescape.conf
|
||||
"
|
||||
|
@ -1,78 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Toggle between tty1 and tty2, launching $KEYBOARD when on tty2
|
||||
# THIS SCRIPT MUST BE RUN AS ROOT
|
||||
# usage:
|
||||
# togglevt.sh <state>
|
||||
# where <state> is an optional arg to require that a counter be incremented before the action
|
||||
# is performed. The default configuration will perform the switch when the power button has
|
||||
# been pressed 3 times whilst the volume down button is being held.
|
||||
# if no arguments are specified the switch will occur immediately.
|
||||
|
||||
[ "$(whoami)" != root ] && echo "This must be run as root" && exit 1
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
test -f /etc/conf.d/ttyescape.conf && . /etc/conf.d/ttyescape.conf
|
||||
|
||||
# default font, override this by setting it in /etc/conf.d/ttyescape.conf
|
||||
FONT="${FONT:-/usr/share/consolefonts/ter-128n.psf.gz}"
|
||||
# amount of times power must be pressed to trigger
|
||||
PRESSCOUNT="${PRESSCOUNT:-3}"
|
||||
TMPFILE="${TMPFILE:-/tmp/ttyescape.tmp}"
|
||||
KEYBOARD="${KEYBOARD:-buffyboard}"
|
||||
|
||||
if [ ! -e /dev/uinput ]; then
|
||||
if ! modprobe -q uinput; then
|
||||
echo "uinput module not available, please enable it in your kernel"
|
||||
fi
|
||||
fi
|
||||
|
||||
switchtty() {
|
||||
currentvt=$(cat /sys/devices/virtual/tty/tty0/active)
|
||||
|
||||
if [ "$currentvt" = "tty2" ]; then # switch to tty1 with normal UI
|
||||
chvt 1
|
||||
killall "$KEYBOARD"
|
||||
else # Switch to tty2 with $KEYBOARD
|
||||
setfont "$FONT" -C /dev/tty2
|
||||
chvt 2
|
||||
# sometimes they keyboard can be running already, we shouldn't start it in that case
|
||||
[ "$(pgrep "$KEYBOARD")" ] || nohup "$KEYBOARD" -r "$(cat /sys/class/graphics/fbcon/rotate)" &
|
||||
fi
|
||||
}
|
||||
|
||||
# If we receive a command that isn't start
|
||||
# and we don't have the file used to count
|
||||
# then we should do nothing
|
||||
if [ -n "$1" ] && [ "$1" != "start" ] && [ ! -f "$TMPFILE" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
# No args means just DO IT
|
||||
"")
|
||||
switchtty
|
||||
;;
|
||||
# Start counting, this should
|
||||
# run when voldown is pressed
|
||||
"start")
|
||||
echo "0" > "$TMPFILE"
|
||||
;;
|
||||
# Run when voldown releases
|
||||
"reset")
|
||||
rm "$TMPFILE"
|
||||
;;
|
||||
# Run when power pressed while
|
||||
# voldown is pressed
|
||||
"inc")
|
||||
val="$(cat "$TMPFILE")"
|
||||
val=$((val+1))
|
||||
if [ $val -eq "$PRESSCOUNT" ]; then
|
||||
rm "$TMPFILE"
|
||||
switchtty
|
||||
else
|
||||
echo "$val" > "$TMPFILE"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
esac
|
@ -1,20 +0,0 @@
|
||||
[[events]]
|
||||
name = "increment"
|
||||
event_type = "EV_KEY"
|
||||
key_state = "released"
|
||||
keys = ["KEY_VOLUMEDOWN", "KEY_POWER"]
|
||||
command = "/usr/bin/togglevt.sh inc"
|
||||
|
||||
[[events]]
|
||||
name = "start"
|
||||
event_type = "EV_KEY"
|
||||
key_state = "pressed"
|
||||
keys = ["KEY_VOLUMEDOWN"]
|
||||
command = "/usr/bin/togglevt.sh start"
|
||||
|
||||
[[events]]
|
||||
name = "reset"
|
||||
event_type = "EV_KEY"
|
||||
key_state = "released"
|
||||
keys = ["KEY_VOLUMEDOWN"]
|
||||
command = "/usr/bin/togglevt.sh reset"
|
Loading…
x
Reference in New Issue
Block a user