Debian Codegraph @

tools/startx.sh

raw
1 #!/bin/bash
2
3 # shellcheck disable=SC2329
4 cleanup() {
5 # Make sure Fenrir is restored on exit of this script
6 echo -n "setting set screen#suspendingScreen=" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
7 }
8
9 # Call the cleanup function on exit of this script
10 trap cleanup EXIT
11
12 # Get the number of the current terminal
13 term=$(tty)
14 term="${term##*tty}"
15
16 # Make sure term is a number, otherwise we're in something like screen, and x will not start.
17 if ! [[ "$term" =~ ^[1-9]+$ ]]; then
18 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."
19 trap - EXIT
20 exit 1
21 fi
22
23 # Suspend the current terminal for Fenrir
24 echo -n "setting set screen#suspendingScreen=$term" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
25
26 # Start the x session
27 command startx
28
29 exit 0