Steve Kemp's Blog Writings relating to Debian & Free Software

Sending commands to your running mail-client

Mon, 17 Mar 2014 12:32:38 GMT

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

[gravitar] Karellen

Submitted at 12:03:13 on 18 March 2014

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

[gravitar] Steve Kemp

Submitted at 12:53:59 on 18 March 2014

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.

 

Comments are closed on posts which are more than ten days old.

Spiral Logo

Search

Recent Posts

Recent Tags

Links

RSS Feed

  • Subscribe to feed