Skip to content
rxvt-unicode perl extension to display inline media using mailcap entry
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



This is a perl extension for rxvt-unicode, inspired by HTerm. What it basically does is react to a specific OSC code, intercepts the following base64 encoded data (which would otherwise be rendered as text), and displays it according to the given mimetype.

Trying this manually would look something like this:

printf "\033]777;mime-funnel;image/png;\007" ; base64 image.png ; echo '!'

So why is this useful? Because it allows displaying arbitrary, base64 encoded media from a console stream, in particular over ssh with no server-side dependencies whatsoever.

The script has a dependency on base64 for decoding, and on run-mailcap (packaged in debian with mime-support) to run an appropiate application for the mimetype (man 5 mailcap), unless configured otherwise, see below.


To install, simply copy (or symlink) the mime-funnel script into your urxvt perl-lib directory, and add it to your list of perl-exts. In an .Xresources, this would look as follows:

URxvt.perl-lib: /path/to/other/stuff:/path/to/repo
URxvt.perl-ext: mime-funnel

Or to just give it a whirl, run urxvt as such:

urxvt --perl-lib /path/to/repository -pe mime-funnel

You can also configure the command to be called by specifying the mime-launcher resource as an sprintf string. The first argument is the mimetype, the second is the temp filename. This defaults to:

URxvt.mime-launcher: run-mailcap '%s:%s'; rm '%2$s';


You can then use the supplied funnel script to display media, or any other way using the interface described above.

funnel image.png

funnel will try to find the mimetype of a provided file using mimetype (packaged with libfile-mimeinfo-perl in debian) if available, but it can also be specified explicitly as a second argument. As a sanity check, files bigger than 1M will be rejected unless the -f option is given. Using - as filename will read data from stdin, this does however require an explicit mimetype.


Running arbitrary mailcap applications simply on specific text output is obviously a big security risk. This output could come from anywhere, say the contents of a mail file or even a wall message. To mitigate this a bit, you can set a security code in your Xresources, like this:

URxvt.funnel-code: mysupersecretcode

If such code is specified, only funnelled data with this code as additional argument will be accepted, as such:

printf "\033]777;mime-funnel;image/png;mysupersecretcode;\007" ; base64 image.png ; echo '!'

Just change the line at the beginning of funnel to use your code with it.


Configurably prompt the user whether to reject funnelled media or not if no security code is given.

You can’t perform that action at this time.