Add systemd file generation to autostart-manage
This commit is contained in:
parent
5dbdf3d311
commit
790f3e8039
2 changed files with 37 additions and 0 deletions
11
autostart-manage/before.sh
Normal file
11
autostart-manage/before.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
service_file="$HOME/.config/systemd/user/autostart@.service"
|
||||
if [ ! -f "$service_file" ]; then
|
||||
_deploy_service_file "$service_file"
|
||||
fi
|
||||
|
||||
target_file="$HOME/.config/systemd/user/autostart.target"
|
||||
if [ ! -f "$target_file" ]; then
|
||||
_deploy_target_file "$target_file"
|
||||
fi
|
26
autostart-manage/lib/systemd_files.sh
Normal file
26
autostart-manage/lib/systemd_files.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_deploy_service_file() {
|
||||
cat <<EOF > "$1"
|
||||
[Unit]
|
||||
Description=Autostart several tools and services
|
||||
StartLimitIntervalSec=120
|
||||
StartLimitBurst=10
|
||||
|
||||
[Service]
|
||||
KillMode=process
|
||||
ExecStart=/bin/sh -c ". \$HOME/.profile && autostart-manage exec '%i'"
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
EOF
|
||||
}
|
||||
|
||||
_deploy_target_file() {
|
||||
cat <<EOF > "$1"
|
||||
[Unit]
|
||||
Description=Current graphical user session
|
||||
Documentation=man:systemd.special(7)
|
||||
RefuseManualStart=no
|
||||
StopWhenUnneeded=no
|
||||
EOF
|
||||
}
|
Loading…
Reference in a new issue