-
Notifications
You must be signed in to change notification settings - Fork 0
/
display-setup-script
executable file
·54 lines (47 loc) · 1.42 KB
/
display-setup-script
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
#!/bin/bash
# Generic bash options which I always use for safety. Not all may be needed for this particular script.
set -o nounset
set -o pipefail
set -o errexit
set -o errtrace
trap 'echo "Error at line $LINENO, exit code is $?" >&2' ERR
shopt -s nullglob
shopt -s failglob
# CONFIGURATION ################################################################
DEBUG=0
LOG='/var/log/thinkpad-w530-dock.log'
################################################################################
if [ "$DEBUG" = 1 ] ; then
touch "$LOG"
chown root:root "$LOG"
chmod 700 "$LOG"
exec &>> "$LOG"
fi
l() {
echo "$(date --rfc-3339=seconds): display-setup-script $$: $@"
}
l "Started..."
if [ $# -ne 1 ] ; then
# We want to wait for bumblebeed to start, but it is started after LightDM.
# So if we don't exit this script now then LightDM will wait for it
# forever, and bumblebee won't be started because of that, so we would be
# deadlocked.
l "Forking worker child process so LightDM doesn't wait for us..."
nohup "$0" "child" &> /dev/null &
exit 0
elif [ "$1" != child ] ; then
l "Unknown argument: $1" >&2
exit 1
fi
l "Child is waiting for bumblebeed to start..."
time=0
while ! pgrep --count bumblebeed > /dev/null ; do
sleep 0.1s
if ((++time >= 600)); then
l "Timed out waiting for bumblebeed! Exiting!" >&2
exit 1
fi
done
l "Finished: bumblebeed running. Calling dock-handler..."
/root/.bin/bumblebee-multiscreen-tools/dock-handler
exit 0