About Archive Tags RSS Feed

 

Sending commands to your running mail-client

17 March 2014 21:50

So I wrote a mail client, and this morning I added the ability for it to receive input from a Unix domain socket.

In one terminal I have my email client open. In another I run:

lumailctl /tmp/foo.sock "open('/home/skx/Maildir/.livejournal.2014/');"

That opens the unix domain socket, and pipes the following command to it:

open('/home/skx/Maildir/.livejournal.2014/');

The mail client has already got the socket open, and the end result is that my mail client suddenly opens the specified mail folder, and redraws itself.

Neat.

The "open" function is obviously a lua function, which builds upon the lua primitives the client understands:

function open( folder )
   clear_selected_folders()
   set_selected_folder(folder)
   index()
end

Obviously this would be woefully insecure if it were released like this. Later I'll wire up some lua function to establish the socket, such that the user specifies where the socket is created (their home directory, ideally), and it doesn't run by default.

| 2 comments

 

Comments on this entry

icon Karellen at 12:03 on 18 March 2014

Wouldn't dbus be a good fit for this? And already include support for authentication?

icon Steve Kemp at 12:53 on 18 March 2014
http://www.steve.org.uk/

Possibly, but I don't run dbus on the remote server to which my mail is delivered - where I read it over ssh.

I'm also not sure how portable dbus is, it could well be available "everywhere" but off the top of my head I don't know that, and my mail client is pretty portable.