It may sound silly, but I wanted wall(1) to do growl. Actually, I wanted rwall
on my Solaris NFS server to end up as a growl notification on my Mac.
Porting an old FreeBSD rpc.rwalld to the Mac wasn't too bad, but that was only
part of the answer. To actually deliver a message to the end user, rpc.rwalld
uses wall, and wall is pretty useless on a Mac, unless one happens to have a
terminal window open.
So I ended up modifying the code for wall to use growlnotify (assuming it to be
available in the usual place) additionally, if delivering to /dev/console.
The attached patch is against the ttymsg.c file within the remote_cmds tarball
corresponding to 10.6.2. (not that the file had changed in awhile)
(tarball at
http://www.opensource.apple.com/tarballs/remote_cmds/remote_cmds-22.tar.gz )
The way I did it is not sophisticated or efficient; but if wall were being run
often enough that efficiency was at issue, it would be seriously annoying, so I
figured it better to keep the code simple and maintainable. Not to mention
that the fancier approaches I wanted meant I'd have had to have understood the
growlnotify code enough to put some of it directly into wall's code...and I
still haven't gotten around to learning Objective C yet!
Silly or not, it always irritated me that wall on a Mac was nearly useless.
Modified like this, it doesn't have to be.
PS if anyone really wants the tarball of the modified rpc.rwalld code (no Xcode
stuff, just a Makefile, the code, and a plist to go in /Library/LaunchDaemons),
email
me; it's so far OT I'm not going to bother attaching it.
--
You received this message because you are subscribed to the Google Groups
"Growl Discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/growldiscuss?hl=en.
*** remote_cmds-22/wall.tproj/ttymsg.c.orig 2008-03-26 04:34:11.000000000
-0400
--- remote_cmds-22/wall.tproj/ttymsg.c 2009-12-19 00:57:56.000000000 -0500
***************
*** 40,45 ****
--- 40,46 ----
#endif
#include <sys/types.h>
+ #include <sys/stat.h>
#include <sys/uio.h>
#include <dirent.h>
#include <errno.h>
***************
*** 53,58 ****
--- 54,76 ----
#include "ttymsg.h"
+ #define GROWLNOTIFY "/usr/local/bin/growlnotify"
+ static void
+ growl(struct iovec *iov, int iovcnt)
+ {
+ FILE *fp;
+ register int i;
+
+ if ((fp=popen(GROWLNOTIFY " --name wall --priority High --title 'Wall
Broadcast Message'", "w")) == NULL)
+ return;
+
+ for (i=0;i<iovcnt;i++)
+ fwrite(iov[i].iov_base, iov[i].iov_len, 1, fp);
+
+ fclose(fp);
+ }
+
+
/*
* Display the contents of a uio structure on a terminal. Used by wall(1),
* syslogd(8), and talkd(8). Forks and finishes in child if write would
block,
***************
*** 76,82 ****
return ("too many iov's (change code in wall/ttymsg.c)");
p = device + sizeof(_PATH_DEV) - 1;
! strlcpy(p, line, sizeof(device));
if (strncmp(p, "pts/", 4) == 0)
p += 4;
if (strchr(p, '/') != NULL) {
--- 94,100 ----
return ("too many iov's (change code in wall/ttymsg.c)");
p = device + sizeof(_PATH_DEV) - 1;
! strlcpy(p, line, sizeof(device) - (sizeof(_PATH_DEV) - 1));
if (strncmp(p, "pts/", 4) == 0)
p += 4;
if (strchr(p, '/') != NULL) {
***************
*** 86,91 ****
--- 104,112 ----
return (errbuf);
}
+ if (strcmp(device, "/dev/console") == 0)
+ growl(iov, iovcnt);
+
/*
* open will fail on slip lines or exclusive-use lines
* if not running as root; not an error.