Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
systemctl cat --user git-sync-powersavehelper
# /home/norangshol/.config/systemd/user/git-sync-powersavehelper.service
[Unit]
Description = Disable and Enable git-sync depending on AC power
ReloadPropagatedFrom = sys-susbsystem-power_supply-main_AC.device
[Service]
ExecStart = /usr/bin/env git-sync-powersavehelper
ExecReload = /usr/bin/env git-sync-powersavehelper
RemainAfterExit=true
[Install]
WantedBy = sys-subsystem-power-supply-main_AC.device
norangshol@enceladus:~$ cat ~/.local/bin/git-sync-powersavehelper
#!/usr/bin/env sh
if /lib/systemd/systemd-ac-power ; then
echo "Power On: $(date)"
else
echo "Battery On: $(date)"
fi
@norrs

This comment has been minimized.

Copy link
Owner Author

@norrs norrs commented Oct 10, 2018

root@enceladus:~# systemctl list-units --type=device | grep -i power_sup
sys-devices-LNXSYSTM:00-LNXSYBUS:00-PNP0A08:00-device:19-PNP0C09:00-ACPI0003:00-power_supply-AC.device loaded active plugged /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/ACPI0003:00/power_supply/AC
sys-subsystem-power_supply-main_AC.device loaded active plugged /sys/subsystem/power_supply/main_AC

@norrs

This comment has been minimized.

Copy link
Owner Author

@norrs norrs commented Oct 10, 2018

$ systemd-analyze verify --user git-sync-powersavehelper.service
norangshol@enceladus:~$ echo $?
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.