Hello!
This is what my status_cmd patch does. It adds a new variable status_cmd.
This is a name of the program that gets called when status line is changed.
The program gets two arguments: old status and new status.
I also attach my script that I use for this. This script parses
the status line and changes the xterm status according
to whether there are new messages and other parameters.
And I do
set status_format="%v: %r %f [%?b?%b mailboxes ,?%M/%m] %?p?[post=%p]?
%?n?[N=%n]?%?t?[*=%t]? <%s>"
set status_cmd="statuscmd"
Hope this helps,
MST
Quoting r. Thomas Dickey ([EMAIL PROTECTED]) "Re: xterm titlebars and
status_format or folder-hook":
> On Wed, Feb 21, 2001 at 05:15:54PM -0500, Rich Lafferty wrote:
> > Hi --
> >
> > I'd like to tell Mutt to echo the appropriate escape codes to change
> > xterm's title bar to the name of the current mailbox. I tried
> > adding them to folder_hook, but the literals "^[" and "^G" get
> > displayed; I couldn't figure out how to tell a folder-hook to cant
> > the magic.
> >
> > Has anyone solved this problem?
>
> you probably cannot, using folder-hook in that way since the message is written
> via the screen library rather than printing directly. perhaps make the folder
> hook invoke an external process such as xtermset (I don't know offhand if mutt
> can do that - the 'exec' command looked promising, but only does internal
> functions).
>
> --
> Thomas E. Dickey <[EMAIL PROTECTED]>
> http://dickey.his.com
> ftp://dickey.his.com
--
This message content is not part of Intel's views or affairs
Michael S. Tsirkin
> Four things are to be strengthened: Torah,and good deeds,
> prayer and one's good manners (Berachoth)
Use vfork instead of fork to speed process creation up
diff -u mutt-1.2-rr/curs_main.c mutt-1.2/curs_main.c
--- mutt-1.2-rr/curs_main.c Thu May 11 19:07:11 2000
+++ mutt-1.2/curs_main.c Thu May 11 19:09:25 2000
@@ -382,7 +382,7 @@
*/
int mutt_index_menu (void)
{
- char buf[LONG_STRING], helpstr[SHORT_STRING];
+ char buf[LONG_STRING], helpstr[SHORT_STRING],status_buf[LONG_STRING]="";
int op = OP_NULL;
int done = 0; /* controls when to exit the "event" loop */
int i = 0, j;
@@ -518,7 +518,22 @@
if (menu->redraw & REDRAW_STATUS)
{
+ static pid_t child=0;
menu_status_line (buf, sizeof (buf), menu, NONULL (Status));
+ /* If StatusCmd is set, and status line changed,
+ * call the appropriate command */
+ /* only do this if the previous child exited. */
+ if (child) {
+ if (waitpid(child, 0, WNOHANG)) child=0;
+ }
+ if (!child && StatusCmd && *StatusCmd && strncmp(buf,status_buf,sizeof (buf)))
+{
+ strncpy(status_buf,buf,sizeof (buf));
+ child=vfork();
+ if (!child) {
+ execlp(StatusCmd,StatusCmd,status_buf,buf,0);
+ exit(1);
+ }
+ }
CLEARLINE (option (OPTSTATUSONTOP) ? 0 : LINES-2);
SETCOLOR (MT_COLOR_STATUS);
printw ("%-*.*s", COLS, COLS, buf);
diff -u mutt-1.2-rr/globals.h mutt-1.2/globals.h
--- mutt-1.2-rr/globals.h Thu May 11 19:07:13 2000
+++ mutt-1.2/globals.h Thu May 11 19:09:25 2000
@@ -91,6 +91,7 @@
WHERE char *Spoolfile;
WHERE char *StChars;
WHERE char *Status;
+WHERE char *StatusCmd;
WHERE char *Tempdir;
WHERE char *Tochars;
WHERE char *Username;
diff -u mutt-1.2-rr/init.h mutt-1.2/init.h
--- mutt-1.2-rr/init.h Thu May 11 19:07:15 2000
+++ mutt-1.2/init.h Thu May 11 19:16:12 2000
@@ -1888,6 +1888,20 @@
{ "status_chars", DT_STR, R_BOTH, UL &StChars, UL "-*%A" },
/*
** .pp
+ ** Specifies the command to be executed each time the status line
+ ** changes.
+ ** The new status line is passed as the first parameter,
+ ** the old one as the second parameter.
+ ** This is useful e.g. to change the xterm window icon title according to the
+ ** status of the mailbox.
+ ** The command can parse the status and do more complicated things, for
+ ** example, bring up a popu menu whenever a new mail arrives, sound a
+ ** bell etc etc.
+ */
+ { "status_cmd", DT_PATH, R_NONE, UL &StatusCmd, 0 },
+
+ /*
+ ** .pp
** Controls the characters used by the "%r" indicator in
** ``$$status_format''. The first character is used when the mailbox is
** unchanged. The second is used when the mailbox has been changed, and
#!/usr/intel/bin/perl
if (($ENV{TERM} eq "vt100") or ( not defined ($ENV{XMUTT} ) ) ) {
exit(1);
}
#open (TTY, "/dev/tty");
$title=$ARGV[0];
$new=0;
@array=split(' ',$title);
if ($title =~ /N=([0-9]+)/o) {
$new=$1;
}
$boxes=0;
if ($title =~ /([0-9]+) mailboxes/o) {
$boxes=$1;
}
$line="";
if ($new or $boxes) {
$line="NEW ".$new."/".$boxes." ";
}
$array[3] =~ s#.*Mail/##;
$line.="MUTT ".$array[3];
#print TTY "]2;$line";
print "]2;$line";