This Gist includes:
-
yadm-autopush.sh
: A script that stages and commits tracked changes in your dotfiles and pushes them to your remote repository. -
yadm-autopush.service
: A systemd user service that executes theyadm-autopush.sh
script. -
yadm-autopush.timer
: A systemd user timer that triggers the service every 6 hours, starting 5 minutes after boot.
Setup Instructions:
-
Create the Script:
Save the following content as
~/.local/bin/yadm-autopush.sh
and make it executable:#!/bin/bash cd ~ || exit 1 yadm add -u if yadm diff --cached --quiet; then exit 0 # Nothing to commit fi yadm commit -m "Auto-push: $(date +'%Y-%m-%d %H:%M')" yadm push
Make the script executable:
chmod +x ~/.local/bin/yadm-autopush.sh
-
Create the Systemd Service:
Save the following content as
~/.config/systemd/user/yadm-autopush.service
:[Unit] Description=Auto-commit and push yadm dotfiles [Service] Type=oneshot ExecStart=/home/yourusername/.local/bin/yadm-autopush.sh
Replace /home/yourusername
with your actual home directory path.
-
Create the Systemd Timer:
Save the following content as
~/.config/systemd/user/yadm-autopush.timer
:[Unit] Description=Run yadm auto-push every 6 hours [Timer] OnBootSec=5min OnUnitActiveSec=6h Persistent=true [Install] WantedBy=default.target
-
Enable and Start the Timer:
Run the following commands to enable and start the timer:
systemctl --user daemon-reload systemctl --user enable --now yadm-autopush.timer
To verify that the timer is active:
systemctl --user list-timers | grep yadm
This setup ensures that your yadm
dotfiles are automatically committed and pushed to your remote repository every 6 hours, starting shortly after your system boots. If you need assistance customizing this setup further or have any questions, feel free to ask!