forked from herbstluftwm/herbstluftwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
valgrind-xephyr.sh
executable file
·54 lines (44 loc) · 1.17 KB
/
valgrind-xephyr.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
#!/usr/bin/env bash
# run a herbstluftwm with valgrind in a xephyr
# run this from a build directory, i.e. directory in which you run make.
die() {
echo "$*" >&2
exit 1
}
set -e
# find free display number
# ------------------------
xephyr_displaynr= # only the display number without the colon
for displaynr in {11..80} ; do
if [[ ! -e /tmp/.X11-unix/X$displaynr ]] ; then
xephyr_displaynr="$displaynr"
break
fi
done
if [[ -z "$xephyr_displaynr" ]] ; then
die "No free display found"
fi
# set up herbstluftwm
# -------------------
export PATH="$(pwd):$PATH"
make herbstluftwm herbstclient
project_dir=$(dirname "$0")
project_dir=${project_dir%/*}
# boot up Xephyr
# --------------
Xephyr -resizeable ":$xephyr_displaynr" &
xephyr_pid=$!
while sleep 0.3; do
echo "Waiting for display :$xephyr_displaynr to appear"
if [[ -e /tmp/.X11-unix/X$xephyr_displaynr ]] ; then
break
fi
done
# boot up herbstluftwm
# --------------------
DISPLAY=":$xephyr_displaynr" \
valgrind -- \
./herbstluftwm --verbose -c "$project_dir"/share/autostart \
|| echo "Warning: valgrind had non-zero exit code"
# clean up xephyr
kill "$xephyr_pid"