mirror of
https://github.com/Rouji/openurl2.git
synced 2026-04-16 04:59:57 +00:00
opens urls
| .github/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
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
dirslib thinks configs go in. On linux, most likelyXDG_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