2007-09-12

Windows WinPopUp messages and Linux

I've known for a while that Samba provides a WinPopUp client, for sending instant messages to Microsoft Windows clients over the network. It’s a facility of the smbclient utility, and can be used like so:

$ smbclient -M SomeWindowsBox
Connected. Type your message, ending it with a Control-D
Hi, Windows user!
sent 19 bytes

The user on the computer named SomeWindowsBox will see the message pop up on their screen (possibly stealing focus and making an annoying dinging sound).

smbclient will also accept input from stdin. For example, to report disk free space remotely:

$ df -h | smbclient -M AdminMachine

It turns out you can also receive such messages on Linux, via Samba’s smbd server daemon. To enable this, add a message command directive in the Samba configuration file of the receiving system (usually /etc/samba/smb.conf). Here is the example from the smb.conf manual page:

message command = csh -c 'xedit %s;rm %s' &

This didn’t work on my Gentoo box for a number of reasons: I hadn't installed the csh or xedit commands, for a start! I also have two X Window System displays, and wanted the pop-up messages to appear on a specific display, requiring the DISPLAY environment variable to be set. Also, I had to use xhost to tell the X server to allow xmessage from the local system to display its goodies.

Here is the setting that I ended up using in smb.conf:

message command = /bin/bash -c 'export DISPLAY=:0.1; /usr/bin/xmessage -file %s; rm %s' &

TODO: integrate with the Ion window manager, perhaps to get the message to appear in an appropriate frame without stealing focus, etc.

No comments: