From 05e3b0b3f90773e5434ce9a2603e865e8fd2564b Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Tue, 11 Jan 2022 14:59:29 -0500 Subject: [PATCH] Added a suspender script for people who want to use startx. --- tools/startx.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tools/startx.sh diff --git a/tools/startx.sh b/tools/startx.sh new file mode 100755 index 00000000..e92a9402 --- /dev/null +++ b/tools/startx.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +cleanup() { + # Make sure Fenrir is restored on exit of this script + echo -n "setting set screen#suspendingScreen=" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock +} + +# Call the cleanup function on exit of this script +trap cleanup EXIT + +# Get the number of the current terminal +term=$(tty) +term="${term##*tty}" + +# Make sure term is a number, otherwise we're in something like screen, and x will not start. +if ! [[ "$term" =~ ^[1-9]+$ ]]; then + echo "This does not appear to be a terminal from where X may be started. Please make sure you are not in a screen or tmux session." + trap - EXIT + exit 1 +fi + +# Suspend the current terminal for Fenrir +echo -n "setting set screen#suspendingScreen=$term" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock + +# Start the x session +command startx + +exit 0