Hello,

This patch adds a new setting that you can configure to execute a
command every time new mail is found in your current mailbox.

In OSX I have it set to the following:
set new_command="terminal-notifier -title '%v' -subtitle 'New Mail in %f' 
-message '%n new messages, %u unread.' -activate %'com.apple.Terminal'; afplay 
%'/Applications/Mail.app/Contents/Resources/New Mail.aiff' &"

The first part will format some information about the status of the
mailbox and pass it on to terminal-notifier
(https://github.com/alloy/terminal-notifier) then use OSX's afplay to
play the classic "new mail" sound.

I'm very interested in hearing what other mutters think about this
patch.

PS - Santiago Torres (CCd) and me pair-programmed this.

Thanks!

Yoshiki.

changeset:   6404:41baf119bb70
tag:         tip
user:        Yoshiki Vazquez Baeza
date:        Tue Jan 27 14:09:59 2015 -0700
summary:     Add setting to execute a command when receiving new mail

diff -r ec93761e3e12 -r 41baf119bb70 curs_main.c
--- a/curs_main.c       Fri Jan 23 10:33:32 2015 -0800
+++ b/curs_main.c       Tue Jan 27 14:09:59 2015 -0700
@@ -575,6 +575,12 @@
          mutt_message _("New mail in this mailbox.");
          if (option (OPTBEEPNEW))
            beep ();
+      if (NewCmd)
+      {
+        char cmd[LONG_STRING];
+        menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewCmd));
+        mutt_system(cmd);
+      }
        } else if (check == M_FLAGS)
          mutt_message _("Mailbox was externally modified.");
 
@@ -596,8 +602,17 @@
        menu->redraw |= REDRAW_STATUS;
      if (do_buffy_notify)
      {
-       if (mutt_buffy_notify () && option (OPTBEEPNEW))
-       beep ();
+       if (mutt_buffy_notify ())
+       {
+         if (option (OPTBEEPNEW))
+           beep ();
+         if (NewCmd)
+         {
+           char cmd[LONG_STRING];
+           menu_status_line(cmd, sizeof(cmd), menu, NONULL(NewCmd));
+           mutt_system(cmd);
+         }
+       }
      }
      else
        do_buffy_notify = 1;
diff -r ec93761e3e12 -r 41baf119bb70 globals.h
--- a/globals.h Fri Jan 23 10:33:32 2015 -0800
+++ b/globals.h Tue Jan 27 14:09:59 2015 -0700
@@ -111,6 +111,7 @@
 WHERE char *PostponeEncryptAs;
 WHERE char *Prefix;
 WHERE char *PrintCmd;
+WHERE char *NewCmd;
 WHERE char *QueryCmd;
 WHERE char *QueryFormat;
 WHERE char *Realname;
diff -r ec93761e3e12 -r 41baf119bb70 init.h
--- a/init.h    Fri Jan 23 10:33:32 2015 -0800
+++ b/init.h    Tue Jan 27 14:09:59 2015 -0700
@@ -290,6 +290,13 @@
   { "beep",            DT_BOOL, R_NONE, OPTBEEP, 1 },
   /*
   ** .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.
+  */
+  { "new_command",     DT_PATH, R_NONE, UL &NewCmd, UL NULL },
+  /*
+  ** .pp
   ** When this variable is \fIset\fP, mutt will beep when an error occurs.
   */
   { "beep_new",                DT_BOOL, R_NONE, OPTBEEPNEW, 0 },

Reply via email to