opens urls
Find a file
2026-04-12 14:18:35 +02:00
.github/workflows add gh workflow 2026-04-12 13:06:36 +02:00
src fmt 2026-04-12 14:18:35 +02:00
.gitignore init 2026-04-12 13:06:33 +02:00
Cargo.lock init 2026-04-12 13:06:33 +02:00
Cargo.toml init 2026-04-12 13:06:33 +02:00
README.md no subdir for config; try different places for config instead of just one 2026-04-12 13:32:46 +02:00

Rust cli program, that registers itself as default browser and opens URLs in different programs/browsers, based on:

  • URL regexes
  • MIME types in HEAD responses

Configured via openurl2.toml in the following locations (first one wins):

  • whatever the dirs lib thinks configs go in. On linux, most likely XDG_CONFIG_HOME
  • (macos only) ~/Library/Preferences
  • ~/.config/

config

Rules are evaluated in order; the first match wins and no further rules are checked.

# Global MIME handlers. Used whenever a rule triggers MIME detection
[mime]
"application/pdf"          = "qpdfview"
"video/*"                  = "mpv"
"audio/*"                  = ["mpv", "--force-window=yes", "%u"]
"text/html"                = "firefox"
"*/*"                      = "firefox"  # catch-all for unrecognized MIME types

# Ordered rules. First match wins
[[rule]]
pattern = "https?://meet\\.google\\.com/.*"
run = "chromium"  # direct launch, no MIME fetch

[[rule]]
pattern = "https?://(www\\.)?youtube\\.com/.*"
run = "mpv"

[[rule]]
pattern = "https?://internal\\.corp/docs/.*"
fetch_mime = true
# override a global MIME handler for this rule only
[rule.mime]
"application/pdf" = "evince"

[[rule]]
# no pattern = matches everything; use as fallback
fetch_mime = true

rules

Field Description
pattern Regex matched against the URL. Omit to match everything (useful as a fallback).
run Program to launch. String (URL appended as last arg) or array (use %u as URL placeholder).
fetch_mime If true, perform a HEAD request and dispatch via MIME type.
[rule.mime] Per-rule MIME overrides. Checked before the global [mime] table.

mime

When fetch_mime = true, the MIME type from the HEAD response is looked up in [rule.mime] first, then in the global [mime] table. Glob patterns (video/*) are supported. If no entry matches, the rule is skipped and matching continues.

Note: Avoid using xdg-open (or similar default-browser launchers) as a handler, if you've registered openurl2 as your default browser, to prevent infinite loops