Skip to content

Instantly share code, notes, and snippets.

@trev-dev
Created June 21, 2022 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trev-dev/efedd98c672ed65a0d5da5981e5dee5e to your computer and use it in GitHub Desktop.
Save trev-dev/efedd98c672ed65a0d5da5981e5dee5e to your computer and use it in GitHub Desktop.
Notmuch sync script
#!/run/current-system/profile/bin/guile -s
!#
(define (nm-tag terms)
(system* "notmuch" "tag" (car terms) "--" (cdr terms)))
(define %post-sync-terms '(("+inbox" . "path:/.*\\/INBOX/")
("+draft" . "path:/.*\\/Drafts/")
("+sent" . "path:/.*\\/Sent/")
("+trash" . "path:/.*\\/Trash/")
("+spam" . "path:/.*\\/Spam/")
("+todo -inbox -sent" . "tag:inbox and tag:sent")
;; Remove tags for moved messages
("-inbox" . "not path:/.*\\/INBOX/")
("-trash" . "not path:/.*\\/Trash/")
("-spam" . "not path:/.*\\/Spam/")
("+work" . "to:trev@trevdev.ca")
("+work" . "to:trevor@voltagenewmedia.com")))
(system* "mbsync" "-a")
(nm-tag '("-new" . "tag:new"))
(system* "notmuch" "new")
(map nm-tag %post-sync-terms)
;; TODO: Notify-send new mail count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment