Re: Unison + launchd?

"'Jason J. Corso' via unison-users" <[email protected]> Sat, 15 Feb 2025 22:24:32 -0500
Newsgroups gmane.network.unison.general
Message-ID <CAO6ZFz7L1kTNXxEM0e4Bq7-ptj82BevpSEy=VuYDPu0aFR4tTg@mail.gmail.com>
Hi Benjamin,

I dug up this script that I was using for a while.  I had this running
hourly in a cronjob.  The notification is macos specific.   It's a simple
hack, really.  But, should work.

---
#!/bin/bash

# Unison profile name (or specify paths directly)
UNISON_PROFILE="..."
MESSAGE="Unison Sync Completed with Changes"

LOG_FILE="/tmp/unison_sync.log"
rm $LOG_FILE

# Run Unison and capture output
unison "$UNISON_PROFILE" -batch -terse > "$LOG_FILE"

# Check if the log file has any content (indicating changes or conflicts)
if [[ -s "$LOG_FILE" ]]; then
    osascript -e "display notification \"$MESSAGE\" with title \"Unison
Sync\""

    logger "Unison Sync: Changes detected. Check $LOG_FILE for details."
fi
---

Thanks,
Jason


On Sat, Feb 15, 2025 at 5:58 PM Benjamin Pierce <[email protected]>
wrote:

> I wonder if anyone has a recipe for periodically running Unison in the
> background (e.g., as a launchd service), and notifying the user (e.g., by
> popping up an alert) only when the sync actually transfers some files or
> runs into a conflict (i.e., when the output is non-empty).  Bonus points if
> it works on MacOS.
>
> Thank you!
>
>    - Benjamin
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].