-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxrun.sh
86 lines (68 loc) · 1.88 KB
/
xrun.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# calculate first available VT
LVT=`fgconsole --next-available`
# calculate first usable display
XNUM="-1"
SOCK="something"
while [ ! -z "$SOCK" ]
do
XNUM=$(( $XNUM + 1 ))
SOCK=$(ls -A -1 /tmp/.X11-unix | grep "X$XNUM" )
done
NEWDISP=":$XNUM"
if [ ! -z "$*" ]
# generate exec line if arguments are given
then
# test if executable exists
if [ ! -x "$(which $1 2> /dev/null)" ]
then
echo "$1: No such executable!"
# if running from X, display zenity dialog:
[ -z "$DISPLAY" ] || zenity --error --text="$1: No such executable!" 2> /dev/null
exit 127
fi
# generate exec line
EXECL="$(which $1)"
shift 1
EXECL="$EXECL $*"
EXECPH=""
# prepare to start new X sessions if no arguments passed
else
EXECL=""
EXECPH="New X session"
fi
# if runing from X, display zenity dialog:
[ -z "$DISPLAY" ] || zenity --question --title "Launch?" --text="Will launch \"$EXECL$EXECPH\"
tty$LVT
X display $NEWDISP
Continue?" 2> /dev/null || exit 1
echo "Will launch \"$EXECL$EXECPH\" on tty$LVT, X display $NEWDISP..."
[ -z "$DISPLAY" ] && sleep 1s
# This flag is used for indication of unaccessible or broken DRI.
# It is set, for example, when using fglrx+compiz-manager.
# Some games will refuse to start if it is set.
# Unsetting it should not do any harm, and can be useful.
unset LIBGL_ALWAYS_INDIRECT
##########################################################
# main execution
xinit $EXECL -- $NEWDISP vt$LVT -nolisten tcp -br &
##########################################################
# set our new dislplay
DISPLAY=$NEWDISP
# wait some time for X to load
sleep 4s
# then we set useful parameters
# disable non-linear mouse acceleration
xset m 1 0
# disable hard-coded default 10m screensaver
xset s 0 0
# while X is running, persistently do something useful
# i.e. prevent apps from enabling mouse acceleration and screensaver
while xset -q > /dev/null
do
xset m 1 0
xset s 0 0
sleep 3s
done
wait
sleep 5