Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save novoid/e42dab4cfdad201d3a53ce3d8c04b583 to your computer and use it in GitHub Desktop.
Save novoid/e42dab4cfdad201d3a53ce3d8c04b583 to your computer and use it in GitHub Desktop.
Checking for syncthing conflict files and adding them to my Org mode agenda
#!/bin/bash
## This script appends to ORGFILE when syncthing conflict files are located on the host.
## setup:
## 1. pip3 install appendorgheading https://github.com/novoid/appendorgheading
## 2. modify ORFGILE to match an Org mode file which is part of your agenda (in order to get notified).
## 3. create a cronjob entry for this script to run, e.g., daily.
HOSTNAME=$(uname -n)
ORGFILE="${HOME}/org/errors.org"
# ORGFILE="testerrors.org" ## for local testing
CONFLICTS=$(locate sync-conflict)
if [ -z "${CONFLICTS}" ]; then
## wc on an empty result would result in one line and thus, one false positive
NUM_CONFLICTS=0
else
NUM_CONFLICTS=$(echo "${CONFLICTS}" | wc -l)
fi
#echo "debug: NUM_CONFLICTS=${NUM_CONFLICTS}"
[ ${NUM_CONFLICTS} -gt 0 ] && /usr/local/bin/appendorgheading --title "Host ${HOSTNAME} has ${NUM_CONFLICTS} syncthing conflicts" \
--quiet \
--section "Please fix this conflicts manually:\n\n#+BEGIN_EXAMPLE\n${CONFLICTS}\n#+END_EXAMPLE\n\n\n " --output "${ORGFILE}"
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment