The opn package

[ Tags: application, bsd3, console, program ] [ Propose Tags ]

The opn command lets you open files and URLs with associated programs. It's intended to "just work" and to be trivial to configure. See the README at for further info.

[Skip to Readme]


Versions 0.1.0, 0.1.1, 0.1.2
Dependencies base (==4.*), directory, filepath, ini, network-uri, optparse-applicative (>=0.10.0), process, text, unordered-containers [details]
License BSD3
Author Anders Claesson
Category Application, Console
Home page
Source repository head: git clone git://
Uploaded Sat Dec 6 21:03:05 UTC 2014 by AndersClaesson
Distributions NixOS:0.1.2
Executables opn
Downloads 665 total (8 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2015-11-13 [all 7 reports]
Hackage Matrix CI


Maintainer's Corner

For package maintainers and hackage trustees

Readme for opn-0.1.2

[back to package description]
  ____  ____  ____
 / __ \/ __ \/ __ \
/ /_/ / /_/ / / / /
\____/ .___/_/ /_/

Build Status

The opn command lets you open files and URLs with associated programs. It's intended to "just work" and to be trivial to configure. Its configuration resides in ~/.opnconfig; here's an example:

browser: chromium

mupdf:    .pdf
emacs:    .lhs .hs .py .c
chromium: .png .jpg .html .txt
mpv:      .avi .mpg .mp4
djview:   .djvu

With this configuration, PDFs would open in mupdf; Haskell, Python and C source files in emacs, etc. If asked to open a file with no matching extension, or a file without an extension, opn tries to be a bit smart. If, for example, one runs

opn foo.h

then the header file foo.h would be opened in emacs. The reason is that such files have mime type text/x-c, and, as files with the extension '.c' shares this mime type, opn "guesses" that '.h' files also should be opened with emacs.

Both [browser] and [associations] sections must be present and nonempty in ~/.opnconfig. The [browser] section should in fact always have exactly one key, namely browser. So a (close to) minimal configuration looks something like this:

browser: chromium

chromium: html

The browser is used for URLs and as a fallback, so with this configuration all files and URLs would open in chromium.

Talking of chromium: on Linux chromium opens downloads using xdg-open. This works pretty well if you are using a full desktop environment like GNOME, KDE or Xfce, but less so if you are running a light window manager such as i3 or xmonad. We can, however, exploit a behavior of xdg-open to effectively replace it with opn. As a fallback, when no supported desktop session is running, xdg-open uses $BROWSER. Thus putting

export BROWSER=opn

in your .bashrc, or something similar for your favorite shell, will "trick" chromium and xdg-open into using opn. This is my own main use for opn.

For further info see the man page: