services: Reorganize services, detect X
Detect X autostart a bit better with a separate service. The service relies on a shell script which searches for a socket which X creates on startup and only finishes when it finds the socket succesfully. This makes services which need X to start successfully a bit more robust, and while it can still break if X takes too long, it should be more stable now. Finally, services can restart more quickly when ended since they don't require the 2+ `RestartSec` option to be present anymore to successfully start.
This commit is contained in:
parent
3fa7f8a6db
commit
7bee413323
24 changed files with 145 additions and 11 deletions
20
services/.local/share/services/x-started-confirm.sh
Executable file
20
services/.local/share/services/x-started-confirm.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
# from: https://superuser.com/questions/759759/writing-a-service-that-depends-on-xorg/1351489#1351489
|
||||
|
||||
COUNTER=0
|
||||
|
||||
while true; do
|
||||
# Check whether or not socket exists
|
||||
if [ -S /tmp/.X11-unix/X0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
((++COUNTER))
|
||||
|
||||
if [ $COUNTER -gt 20 ]; then
|
||||
printf "X did not start in time\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "X not yet started, counter at %s\n" "$COUNTER"
|
||||
sleep 1
|
||||
done
|
||||
Loading…
Add table
Add a link
Reference in a new issue