]> granicus.if.org Git - mutt/commitdiff
NewMailCmd: optionally execute a command upon new mail arrival
authorYoshiki Vázquez Baeza <yoshiki89@gmail.com>
Sun, 7 Jan 2018 13:49:45 +0000 (14:49 +0100)
committerFabian Groffen <grobian@gentoo.org>
Mon, 8 Jan 2018 08:13:29 +0000 (09:13 +0100)
This setting allows to run any external program to e.g. produce a
notification on the desktop when Mutt finds new mail.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
curs_main.c
globals.h
init.h

index 19e39051995bb557645465fbb0dfa388cd51716c..b2c18cad5dfd4fe3a15969c86899b4105cf43b2d 100644 (file)
@@ -636,6 +636,12 @@ int mutt_index_menu (void)
          mutt_message _("New mail in this mailbox.");
          if (option (OPTBEEPNEW))
            beep ();
+         if (NewMailCmd)
+         {
+           char cmd[LONG_STRING];
+           menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewMailCmd));
+           mutt_system(cmd);
+         }
        } else if (check == MUTT_FLAGS)
          mutt_message _("Mailbox was externally modified.");
 
@@ -662,6 +668,12 @@ int mutt_index_menu (void)
          menu->redraw |= REDRAW_STATUS;
          if (option (OPTBEEPNEW))
            beep();
+        if (NewMailCmd)
+        {
+          char cmd[LONG_STRING];
+          menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewMailCmd));
+          mutt_system(cmd);
+        }
        }
      }
      else
index 9634691a48dcf986e701199238b8a35e27c9593a..61b9515740fbf79c255ff231bf7837e31a599bb9 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -115,6 +115,7 @@ WHERE char *Postponed;
 WHERE char *PostponeEncryptAs;
 WHERE char *Prefix;
 WHERE char *PrintCmd;
+WHERE char *NewMailCmd;
 WHERE char *QueryCmd;
 WHERE char *QueryFormat;
 WHERE char *Realname;
diff --git a/init.h b/init.h
index 13505a2132e5bb7d24368843a0ec7db79e32eb4f..d99a25716c8b361b7d3df4c4a8a45f1506f1abd4 100644 (file)
--- a/init.h
+++ b/init.h
@@ -1800,6 +1800,13 @@ struct option_t MuttVars[] = {
    ** See also $$read_inc, $$write_inc and $$net_inc.
    */
 #endif
+  { "new_mail_command",        DT_PATH, R_NONE, UL &NewMailCmd, UL NULL },
+  /*
+  ** .pp
+  ** If \fIset\fP, Mutt will call this command after a new message is received.
+  ** See the $$status_format documentation for the values that can be formatted
+  ** into this command.
+  */
   { "pager",           DT_PATH, R_NONE, UL &Pager, UL "builtin" },
   /*
   ** .pp