Skip to content

Instantly share code, notes, and snippets.

Last active February 24, 2024 20:59
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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.
orgzly_sync() {
# if you are using orgzly-revived use the following instead:
# am broadcast -n com.orgzlyrevived/ -a com.orgzly.intent.action.SYNC_START
am broadcast -n com.orgzly/ -a com.orgzly.intent.action.SYNC_START
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 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.

Copy link

Nice, this is awesome -- even periodically (e.g every hour) running orgzly_sync (if you don't wanna mess with inotify etc) is already going to massively reduce the chances of a conflict.

Btw I'm not sure

|| termux-notification --content "orgzly sync failed"

is going to work as you expect it to -- am broadcast doesn't receive the result back from orgzly. In fact, even if you make a typo in the broadcast target, it still returns code 0, unfortunately.

Copy link

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)

Copy link

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

Copy link

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