Agent Loop Design

Poll Cycle

Every 5 minutes (configurable):
  1. Check /from/hq/kindle/queue/ for new docs
     or check Forgejo webhook for seedbank pushes
  2. If queue non-empty:
     a. Open telnet connection to Kindle IP
     b. Run: cat /proc/$(pidof reader.lua)/status  (is KOReader running?)
     c. If KOReader not running: launch it
     d. Push doc: nc Kindle_IP 2323 < doc.txt
     e. Place doc in KOReader's library path
     f. Trigger KOReader to refresh library
     g. Log to /from/hq/kindle/log/pushed.log
  3. Close telnet, sleep 5 minutes

KOReader File Locations (Post-JB)

/mnt/us/documents/           — USB-visible documents folder
/mnt/us/koreader/            — KOReader app directory
/mnt/us/koreader/history/    — Reading progress, bookmarks