Micron Document
launch email from offpunk

Offpunk has a few new social features: reply and share. These want to call an external email program and pass a T383838mailto: link at it. That's a pretty good way to do it, but what if I want to call Mutt as my mail handler, with custom arguments, and I want it to open up in a new tmux split so I can see the thing I'm replying to or sharing?

That's not too hard, just need a T383838.desktop file with a command in it, and to set that T383838.desktop file as the handler for that url schema.

Turns out, T383838XDG stuff is pretty straightforward to customize with just user-level permissions, which makes a lot of sense.

So I needed the following:

• the tmux command to run
• the T383838.desktop file to handle it
• to call the schema registration thing

The Tmux Command

First the Mutt Command

I recently set up multiple mailboxes in mutt, and it has a habit of picking the wrong one when I use the standard T383838mailto: handling in mutt. So instead of doing that, I want to do this:

mutt -e "set from='Stephen <stephen@thatit.be>'"

And now I can do that to launch Mutt and it will use the right address.

Now Tmux

But I want to call that from Tmux so that I get a nice split if I reply or share, that syntax looks like this:

tmux split-window $command

So my (almost) final command I want to do on handling T383838mailto: looks like this:

tmux split-window mutt -e "set from='stephen <stephen@thatit.be>'"

Create the T383838.desktop file

Using the Tmux command, the T383838.desktop file should look something like this:

[Desktop Entry]
Exec=/usr/local/bin/tmux split-window mutt -e "set from='Stephen <ste
phen@thatit.be>'"
Name=email
Terminal=false
Type=Application
Version=1.5

And that file can go in T383838~/.local/share/applications/email.desktop.

Except I use nix, and I'm not going to do that.

I happen to be using home manager on this system, so I'm going to add the following to my T383838home-manager.users.stephen attribute set.

xdg.desktopEntries.email = {
name = "email";
exec = ''${pkgs.tmux}/bin/tmux split-window mutt -e "set from='Stephen <stephen@thatit.be>'"'';
};

Register the Schema

With a T383838email.desktop file in an XDG approved location, such as T383838~/.local/share/applications/email.desktop the command to add the handler for the current user is:

xdg-settings set default-url-scheme-handler mailto email.desktop

But as I mentioned before, I'm on nix, so I put this attribute set into my T383838home-manager.users.stephen attribute set instead:

xdg.mimeApps = {
enable = true;
defaultApplications = {
"x-scheme-handler/mailto" = "email.desktop";
};
};

Then after a T383838nixos-rebuild switch I can query to see what my mail handler is:

xdg-settings get default-url-scheme-handler mailto

And I see the cheerful output that confirms it's set:

email.desktop

Using it

Now when I'm browsing a page in Offpunk, I can type T383838reply and it will pop open mutt in a new split and in the typical T383838malto: handling fashion, the current page title becomes the subject line and the recipient will be filled out, too. Offpunk does a pretty good job of figuring out the recipient.

Tags: index, offpunk

Tags
Navigation





created: 2026-02-09

(re)generated: 2026-07-17