scripts: Regularly index the mail directory.
authorRicardo Wurmus <rekado@elephly.net>
Sun, 21 Jul 2019 10:30:44 +0000 (12:30 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Sun, 21 Jul 2019 11:11:39 +0000 (13:11 +0200)
* configure.ac: Detect mu.
* guix.scm: Add "mu" to the environment.
* mumi/config.scm.in (%config)[mu-executable]: Add it.
* scripts/mumi.in: Spawn "mu index" regularly.

configure.ac
guix.scm
mumi/config.scm.in
scripts/mumi.in

index f24c741..8b66861 100644 (file)
@@ -31,6 +31,8 @@ if test "x$have_fibers" != "xyes"; then
   AC_MSG_ERROR([Guile fibers is missing; please install it.])
 fi
 
+AC_PATH_PROG([MU], [mu])
+
 guilemoduledir="${datarootdir}/guile/site/${GUILE_EFFECTIVE_VERSION}"
 AC_SUBST([guilemoduledir])
 AC_SUBST([GUILE_EFFECTIVE_VERSION])
index 03535c2..dfda6cd 100644 (file)
--- a/guix.scm
+++ b/guix.scm
@@ -73,7 +73,8 @@
      ("guile-json" ,guile-json)
      ("guile-fibers" ,guile-fibers)
      ("guile-syntax-highlight" ,guile-syntax-highlight)
-     ("guile" ,guile-2.2)))
+     ("guile" ,guile-2.2)
+     ("mu" ,mu)))
   (native-inputs
    `(("autoconf" ,autoconf)
      ("automake" ,automake)
index 098e2e8..9d8a9c3 100644 (file)
@@ -46,6 +46,7 @@
            (submission-bug-email-address . "bug-guix@gnu.org")
            (lists       . ("guix-patches@gnu.org" "bug-guix@gnu.org"))
            (packages    . ("guix-patches" "guix"))
+           (mu-executable . "@MU@")
            (debbugs     . ,%gnu)
            (debbugs-domain . "debbugs.gnu.org"))))
     (lambda (key)
index 2abfd51..3bd34f4 100644 (file)
       (when repl-port
         (spawn-server (make-tcp-server-socket #:port repl-port)))))))
 
+;; Keep indexing the mail directory
+(define %mu-index-interval 30)
+(define mu-index
+  (let ((mu (%config 'mu-executable)))
+    (lambda _
+      (let* ((maildir (%config 'mail-dir))
+             (args (list "index"
+                         "--quiet"
+                         (format #f "--muhome=~a" maildir)
+                         (format #f "--maildir=~a" maildir))))
+        (unless (zero? (apply system* mu args))
+          (format (current-error-port)
+                  "Failed to run `~a'~%" command))
+        (alarm %mu-index-interval)))))
+(sigaction SIGALRM mu-index 0)
+(mu-index)
+
 (start-mumi-web-server 1234)