add charging watchdog
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
{{- if eq .chezmoi.os "linux" -}}
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Enable the battery charge-controller watchdog.
|
||||
#
|
||||
# Re-runs whenever the unit or the watchdog script changes, so that an
|
||||
# already-running instance picks up the new version.
|
||||
|
||||
set -e
|
||||
[ "${CHEZMOI}" -eq 1 ] || exit 1
|
||||
|
||||
# unit hash: {{ include (joinPath .chezmoi.sourceDir "dot_config/systemd/user/battery-charge-watchdog.service") | sha256sum }}
|
||||
# script hash: {{ include (joinPath .chezmoi.sourceDir "dot_config/scripts/executable_battery-charge-watchdog.sh") | sha256sum }}
|
||||
|
||||
# Applying from a TTY or a container has no user bus; skip rather than
|
||||
# aborting the whole apply.
|
||||
if ! systemctl --user show-environment > /dev/null 2>&1; then
|
||||
echo "No systemd user session, skipping battery-charge-watchdog activation"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
systemctl --user daemon-reload
|
||||
|
||||
# The unit carries ConditionPathExists on the battery, so enabling it on a
|
||||
# machine without one is harmless: it simply never starts.
|
||||
systemctl --user enable --now battery-charge-watchdog.service
|
||||
|
||||
# enable --now will not restart an instance that is already running, so an
|
||||
# updated script or unit would otherwise not take effect until next login.
|
||||
systemctl --user try-restart battery-charge-watchdog.service
|
||||
|
||||
# vim: syntax=bash ft=template
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user