### HTML
ext x?html?, has vim, terminal = $EDITOR "$1"
ext x?html?, has firefox, X, flag f = firefox -- "$@"
ext x?html?, has lynx, terminal = lynx -- "$@"
ext x?html?, has xdg-open, X, flag f = xdg-open "$@"

### Text
mime ^text, label editor = "$EDITOR" -- "$@"
mime ^text, label pager = "$PAGER" -- "$@"
!mime ^text, label editor, ext xml|csv|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
!mime ^text, label pager, ext xml|csv|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
mime ^text, has xdg-open, X, flag f = xdg-open "$@"

ext 1 = man "$1"
ext s[wmf]c, has zsnes, X = zsnes "$1"
ext nes, has fceux, X = fceux "$1"
ext exe = wine "$1"
name ^[mM]akefile$ = make

### Code
ext py = python -- "$1"
ext pl = perl -- "$1"
ext rb = ruby -- "$1"
ext sh = sh -- "$1"
ext php = php -- "$1"

### Audio without X
mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
ext midi?, terminal, has wildmidi = wildmidi -- "$@"

## Video/Audio with a GUI
mime ^video, has mpv, X, flag f = mpv -- "$@"
mime ^video, has vlc, X, flag f = vlc -- "$@"
mime ^video, has xdg-open, X, flag f = xdg-open "$@"
mime ^audio, has audacious, X, flag f = audacious "$@"
mime ^audio, has xdg-open, X, flag f = xdg-open "$@"

## Image Viewing:
mime ^image, has viewnior, X, flag f = viewnior -- "$@"
mime ^image, has gimp, X, flag f = gimp -- "$@"
mime ^image, has inkscape, X, flag f = gimp -- "$@"
mime ^image, has xdg-open, X, flag f = xdg-open "$@"
ext xcf, X, flag f = gimp -- "$@"

## Documents
ext pdf, has evince, X, flag f = evince -- "$@"
ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has libreoffice, X, flag f = libreoffice "$@"
ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has soffice, X, flag f = soffice "$@"
ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has ooffice, X, flag f = ooffice "$@"
ext djvu, has evince, X, flag f = evince -- "$@"
ext pdf|djvu, has xdg-open, X, flag f = xdg-open "$@"
ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric, has xdg-open, X, flag f = xdg-open "$@"

## Archives, this requires atool
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = aunpack -- "$@"
ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = aunpack -- "$@"

## Fallback:
ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
ext tar|gz, has tar = tar vvxf "$@"
ext zip|rar|deb|7z|tar|gz|bz2*|tgz|xz|cab|jar, has xdg-open, X, flag f = xdg-open "$@"

## Misc
label wallpaper, number 11, mime ^image, X = hsetroot -cover "$1"
label wallpaper, number 12, mime ^image, X = hsetroot -tile "$1"
label wallpaper, number 13, mime ^image, X = hsetroot -center "$1"
label wallpaper, number 14, mime ^image, X = hsetroot -fill "$1"

## Define the editor for non-text files & pager as last action
 !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = ask
label editor, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
label pager, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
