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
|
@ -0,0 +1 @@
|
|||
../x-started-confirm.service
|
8
services/.config/systemd/user/dirmngr.service
Normal file
8
services/.config/systemd/user/dirmngr.service
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=GnuPG network certificate management daemon
|
||||
Documentation=man:dirmngr(8)
|
||||
Requires=dirmngr.socket
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/dirmngr --supervised
|
||||
ExecReload=/usr/bin/gpgconf --reload dirmngr
|
11
services/.config/systemd/user/dirmngr.socket
Normal file
11
services/.config/systemd/user/dirmngr.socket
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=GnuPG network certificate management daemon
|
||||
Documentation=man:dirmngr(8)
|
||||
|
||||
[Socket]
|
||||
ListenStream=%t/gnupg/S.dirmngr
|
||||
SocketMode=0600
|
||||
DirectoryMode=0700
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
|
@ -1,13 +1,13 @@
|
|||
[Unit]
|
||||
Description=Alacritty window hidden on i3 scratchpad
|
||||
After=display-manager.service
|
||||
Requires=x-started-confirm.service
|
||||
After=x-started-confirm.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
# workaround to allow relative executable invocation (i.e. current users' home dir)
|
||||
ExecStart=/bin/bash -c 'alacritty --title "dropdown-terminal" --class Alacritty,scratchpad'
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
[Unit]
|
||||
Description=Todo.md floating vim instance
|
||||
After=display-manager.service
|
||||
Requires=x-started-confirm.service
|
||||
After=x-started-confirm.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
# workaround to allow relative executable invocation (i.e. current users' home dir)
|
||||
ExecStart=/bin/bash -c 'alacritty --title "dropdown-todo" --class "Alacritty,scratchpad" -e nvim -c ":set nonumber norelativenumber noshowmode noruler laststatus=0 noshowcmd shortmess=F | :Limelight" %h/documents/records/todo.md'
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
[Unit]
|
||||
Description=Perform windows animations on focus
|
||||
PartOf=graphical-session.target
|
||||
After=graphical-session.target
|
||||
Requires=x-started-confirm.service
|
||||
After=x-started-confirm.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/flashfocus
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
|
13
services/.config/systemd/user/gpg-agent-browser.socket
Normal file
13
services/.config/systemd/user/gpg-agent-browser.socket
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=GnuPG cryptographic agent and passphrase cache (access for web browsers)
|
||||
Documentation=man:gpg-agent(1)
|
||||
|
||||
[Socket]
|
||||
ListenStream=%t/gnupg/S.gpg-agent.browser
|
||||
FileDescriptorName=browser
|
||||
Service=gpg-agent.service
|
||||
SocketMode=0600
|
||||
DirectoryMode=0700
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
13
services/.config/systemd/user/gpg-agent-extra.socket
Normal file
13
services/.config/systemd/user/gpg-agent-extra.socket
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=GnuPG cryptographic agent and passphrase cache (restricted)
|
||||
Documentation=man:gpg-agent(1)
|
||||
|
||||
[Socket]
|
||||
ListenStream=%t/gnupg/S.gpg-agent.extra
|
||||
FileDescriptorName=extra
|
||||
Service=gpg-agent.service
|
||||
SocketMode=0600
|
||||
DirectoryMode=0700
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
13
services/.config/systemd/user/gpg-agent-ssh.socket
Normal file
13
services/.config/systemd/user/gpg-agent-ssh.socket
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=GnuPG cryptographic agent (ssh-agent emulation)
|
||||
Documentation=man:gpg-agent(1) man:ssh-add(1) man:ssh-agent(1) man:ssh(1)
|
||||
|
||||
[Socket]
|
||||
ListenStream=%t/gnupg/S.gpg-agent.ssh
|
||||
FileDescriptorName=ssh
|
||||
Service=gpg-agent.service
|
||||
SocketMode=0600
|
||||
DirectoryMode=0700
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
8
services/.config/systemd/user/gpg-agent.service
Normal file
8
services/.config/systemd/user/gpg-agent.service
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=GnuPG cryptographic agent and passphrase cache
|
||||
Documentation=man:gpg-agent(1)
|
||||
Requires=gpg-agent.socket
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/gpg-agent --supervised
|
||||
ExecReload=/usr/bin/gpgconf --reload gpg-agent
|
12
services/.config/systemd/user/gpg-agent.socket
Normal file
12
services/.config/systemd/user/gpg-agent.socket
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=GnuPG cryptographic agent and passphrase cache
|
||||
Documentation=man:gpg-agent(1)
|
||||
|
||||
[Socket]
|
||||
ListenStream=%t/gnupg/S.gpg-agent
|
||||
FileDescriptorName=std
|
||||
SocketMode=0600
|
||||
DirectoryMode=0700
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
|
@ -1 +0,0 @@
|
|||
/home/marty/.config/systemd/user/flashfocus.service
|
|
@ -1,2 +1,3 @@
|
|||
[Service]
|
||||
RestartSec=5
|
||||
[Unit]
|
||||
Requires=x-started-confirm.service
|
||||
After=x-started-confirm.service
|
||||
|
|
8
services/.config/systemd/user/mbsync.service
Normal file
8
services/.config/systemd/user/mbsync.service
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Mailbox synchronization service
|
||||
Wants=network-online.target gpg-agent.socket
|
||||
After=network.target network-online.target dbus.socket gpg-agent.socket
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/home/marty/.local/bin/mail-check
|
10
services/.config/systemd/user/mbsync.timer
Normal file
10
services/.config/systemd/user/mbsync.timer
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Mailbox synchronization timer
|
||||
|
||||
[Timer]
|
||||
OnBootSec=1m
|
||||
OnUnitActiveSec=1h
|
||||
Unit=mbsync.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
|
@ -1,2 +1,3 @@
|
|||
[Service]
|
||||
RestartSec=10
|
||||
[Unit]
|
||||
Requires=x-started-confirm.service
|
||||
After=x-started-confirm.service
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../dirmngr.socket
|
|
@ -0,0 +1 @@
|
|||
../gpg-agent-browser.socket
|
|
@ -0,0 +1 @@
|
|||
../gpg-agent-extra.socket
|
|
@ -0,0 +1 @@
|
|||
../gpg-agent-ssh.socket
|
|
@ -0,0 +1 @@
|
|||
../gpg-agent.socket
|
1
services/.config/systemd/user/timers.target.wants/mbsync.timer
Symbolic link
1
services/.config/systemd/user/timers.target.wants/mbsync.timer
Symbolic link
|
@ -0,0 +1 @@
|
|||
../mbsync.timer
|
10
services/.config/systemd/user/x-started-confirm.service
Normal file
10
services/.config/systemd/user/x-started-confirm.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Monitor status of X server start
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash -c '%h/.local/share/services/x-started-confirm.sh'
|
||||
RestartSec=2
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
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…
Reference in a new issue