Skip to content

Instantly share code, notes, and snippets.

@fabian-thomas
Last active May 28, 2024 19:45
Show Gist options
  • Save fabian-thomas/6f559d0b0d26737cf173e41cdae5bfc8 to your computer and use it in GitHub Desktop.
Save fabian-thomas/6f559d0b0d26737cf173e41cdae5bfc8 to your computer and use it in GitHub Desktop.
Orgzly auto syncronisation for sync tools like syncthing. See orgzly/orgzly-android#8.
#!/data/data/com.termux/files/usr/bin/bash
# https://github.com/orgzly/orgzly-android/issues/8
orgzly_sync() {
# if you are using orgzly-revived use the following instead:
# am broadcast -n com.orgzlyrevived/com.orgzly.android.ActionReceiver -a com.orgzly.intent.action.SYNC_START
am broadcast -n com.orgzly/com.orgzly.android.ActionReceiver -a com.orgzly.intent.action.SYNC_START
}
orgzly_sync
inotifywait --quiet --recursive --monitor --event "close_write,move,delete,create" --exclude "\.git" "/sdcard/org" | while read -r _ _; do
read -r -d '' -t "0.5" -n 10000
orgzly_sync
done

Orgzly auto syncronisation is not yet implemented for remote repositories such as local repos synced with, e.g., syncthing. See orgzly/orgzly-android#8. While other scripts proposed in the linked issue fix the problem, I've compressed those into a simple script. The script is meant for use in termux. Install the Termux-boot plugin. Then put the script into ~/.termux/boot. Now it should automatically run all the time after Android startup.

I use the script for the /sdcard/org directory. This is the directory of my local repository. Insert the path you use there.

@fabian-thomas
Copy link
Author

fabian-thomas commented Feb 19, 2023

Yeah, I'm not sure where I got that from. I guess this could just be removed. (I've removed it)

@fabian-thomas
Copy link
Author

Turns out that you can even use the Termux-boot plugin. I'm gonna update the readme.

@fabian-thomas
Copy link
Author

Added instructions on how to use it with orgzly-revived.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment