-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzxdm
executable file
·101 lines (73 loc) · 2.17 KB
/
zxdm
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
wmdir=${wmdir:-"$HOME/.config/zdm"} # the dir of this display manager
wmconf=$wmdir/zdm.conf
$wmconf # run zdm.conf
autochmod=${autochmod:-"false"} # disable autochmod to make wm scripts to run
sx() {
# sx - start an xserver
# requires xauth Xorg /dev/urandom
cleanup() {
if [ "$pid" ] && kill -0 "$pid" 2> /dev/null; then
kill "$pid"
wait "$pid"
xorg=$?
fi
if ! stty "$stty"; then
stty sane
fi
xauth remove :"$tty"
if [ "$1" = exit ]; then
exit "${xorg:-0}"
fi
}
stty=$(stty -g)
tty=$(tty)
tty=${tty#/dev/tty}
cfgdir=${XDG_CONFIG_HOME:-$HOME/.config}/sx
datadir=${XDG_DATA_HOME:-$HOME/.local/share}/sx
mkdir -p -- "$cfgdir" "$datadir"
export XAUTHORITY="${XAUTHORITY:-$datadir/xauthority}"
touch -- "$XAUTHORITY"
xauth add :"$tty" MIT-MAGIC-COOKIE-1 "$(od -An -N16 -tx /dev/urandom | tr -d ' ')"
trap 'cleanup; trap - INT; kill -INT "$$"' INT
trap 'cleanup exit' EXIT HUP TERM QUIT
# Xorg will check whether it inherited a USR1 with a disposition of SIG_IGN and
# use this state to reply back to the parent process with its own USR1.
# This is done to indicate that the server is ready to accept connections.
# Taking advantage of this feature allows launching the client directly from a
# USR1 signal trap which obviates the need to poll for server readiness.
trap 'DISPLAY=:$tty exec "${@:-$cfgdir/sxrc}" & wait "$!"' USR1
(trap '' USR1 && exec Xorg :"$tty" -keeptty vt"$tty" -noreset -auth "$XAUTHORITY") & pid=$!
wait "$pid"
}
listwm=$(ls -1 $wmdir | grep -v "zdm.conf")
tty=$(tty | grep "tty")
#echo "$listwm"
echo "$(echo "$listwm" | awk '{print "[" NR "]", $0 }' | tr '\n' ' ')"
read wmread
wm=$(echo "$listwm" | grep "$wmread")
if ! [[ -n ${wmread//[0-9]/} ]]; then
wm=$(echo "$listwm" | sed -n "$wmread{p;q}")
fi
echo "$wm"
wmcontent=$(cat $wmdir/$wm)
if [ -z "$wmcontent" ]
then
echo "no file or empity $wmdir/$wm"
else
execwm="$wm"
fi
if ! [ "$autochmod" = "false" ]
then
chmod +x $wmdir/$w
fi
if [ -z "$tty" ]
then
echo "not tty"
echo "if this was a tty 'exec sx sh $wmdir/$execwm'"
else
echo "tty"
echo $session
#exec dbus-launch --sh-syntax --exit-with-session $wm
sx sh $wmdir/$execwm
fi