Created
March 24, 2015 13:41
-
-
Save blipp/21ab6eec5d8d3e1f81ef to your computer and use it in GitHub Desktop.
xinit with automatic detection of X display number and virtual terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO: test if the X server's -displayfd option for automatic detection of a | |
# free X display works | |
get_next_display_number() { | |
local DISPLAY_NUM=0 | |
while [ $DISPLAY_NUM -lt 10 ]; do | |
if [ -e /tmp/.X$DISPLAY_NUM-lock ] | |
then | |
let DISPLAY_NUM=$DISPLAY_NUM+1 | |
else | |
echo $DISPLAY_NUM | |
exit | |
fi | |
done | |
} | |
DISPLAY_NUM=$(get_next_display_number) | |
echo "Starting xinit on X display $DISPLAY_NUM and virtual terminal $XDG_VTNR." | |
echo "If it doesn't work, use the following command with another number after the colon:" | |
echo "\$ xinit -- :$DISPLAY_NUM vt$XDG_VTNR" | |
sleep 1 | |
xinit -- :$DISPLAY_NUM vt$XDG_VTNR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment