Automatically synchronise an Obsidian vault with a Git repository
- Shell 98.2%
- Makefile 1.8%
`notify` posted failure alerts with `-u critical`, which GNOME treats as resident, so they never expire on their own. `notify_clear` only removed the throttle stamp file; it never took the banner down, so a backup that failed once and then recovered left a permanent banner on screen. `notify` now records the id of the notification it posts, and `notify_clear` closes that notification. The id has to come from the `org.freedesktop.Notifications.Notify` D-Bus method via `gdbus`, since `notify-send --print-id` only arrived in libnotify 0.8 and Ubuntu ships 0.7.9; when `gdbus` is absent, notifications still fall back to plain `notify-send` with no id recorded. The recorded id is stored alongside the kernel boot id and only acted on when that still matches, since notification ids restart at 1 when the notification server does, so an id recorded before a reboot would otherwise close an unrelated notification that inherited the number. `notify` also now closes the previous alert before posting a new one, so continuous failure keeps one banner rather than stacking one per throttle window. The DISPLAY / DBUS_SESSION_BUS_ADDRESS discovery for cron is pulled out of `notify` into `notify_env`, since `notify_clear` needs it too on the success path, where cron leaves neither variable set. That move also fixes a stderr leak: reading /proc/<pid>/environ fails under Ubuntu's ptrace scope for processes that are not descendants, and the resulting "Permission denied" was reaching stderr and getting mailed by cron. The 2>/dev/null now precedes the input redirect so it is in place before the open can fail. |
||
|---|---|---|
| .github/workflows | ||
| LICENCE | ||
| Makefile | ||
| obsync.sh | ||
| README.md | ||
| utils.sh | ||
obsync
Synchronises an Obsidian vault to a Git repository. Can be run automatically with cron. For example,
$ crontab -e
0 * * * * cd $HOME/projects/obsync && /bin/bash obsync.sh $HOME/obsidian-vault
Format
Using shfmt.
$ make fmt
Lint
Using shellcheck.
$ make lint