xdg-sanity/README.md

68 lines
2.2 KiB
Markdown
Raw Normal View History

2022-09-08 02:06:14 +00:00
The `xdg-sanity` script is built to replace your default web browser in your
desktop/XDG settings. It intercepts http/s URIs sent to the default browser by
`xdg-open` and sends it to the appropriate application. For example, it will
2022-09-22 02:03:02 +00:00
send `image/jpeg` MIME type files to your image viewer.
2022-09-02 06:42:26 +00:00
2022-09-08 02:06:14 +00:00
## Installation
2022-11-08 06:16:23 +00:00
### Arch Linux
2022-09-08 02:06:14 +00:00
I maintain a package [on the
AUR](https://aur.archlinux.org/packages/xdg-sanity).
### From Source
2022-11-08 06:38:07 +00:00
Dependencies:
- `curl(1)`
2023-03-22 17:49:02 +00:00
- `handlr(1)`
- [`tomcat(1)`](https://git.tebibyte.media/emma/tomcat) (optional; enables
[extensions](#extensions))
2022-11-08 06:38:07 +00:00
Instructions:
Clone this repository and move the `xdg-sanity` binary wherever your operating
2023-03-22 17:49:02 +00:00
system stores locally-installed binaries. This is usually `/usr/local/bin/` or
`"$HOME/.local/bin/"` for your user. Make sure the installation location is in
your `$PATH`.
2022-09-22 02:03:02 +00:00
2023-03-22 17:49:02 +00:00
Create an `xdg-sanity.desktop` file, placing it where your OS stores
locally-installed `.desktop` files, which is usually
`/usr/local/share/applications` or `$XDG_DATA_HOME/applications` for your user.
Set your default web browser to that `.desktop` file using `handlr set`.
2022-11-08 06:38:07 +00:00
#### Extensions
2023-03-22 17:49:02 +00:00
Extensions are written using TOML and are stored in either
2022-11-08 06:38:07 +00:00
`/usr/share/xdg-sanity` when installed from a package manager,
2023-03-22 17:49:02 +00:00
`/usr/local/share/xdg-sanity` when installed locally, or
2022-11-08 06:38:07 +00:00
`$XDG_DATA_HOME/xdg-sanity` for your user.
2023-03-22 17:49:02 +00:00
Extension support requires the installation of the `tomcat(1)` tool, which
parses TOML for the command line.
2022-11-08 06:38:07 +00:00
There are two types of extensions: MIME and replace. MIME extensions are parsed
first and replace the MIME type of the content being fetched. Replace extensions
change the URI passed to the command to another.
The type of the extension depends on the file name. MIME extensions should have
a name ending in `-mime.toml` and replace extensions should have
`-replace.toml`.
Here's what a MIME extension looks like:
```
2022-11-08 06:48:56 +00:00
$ cat $XDG_DATA_HOME/xdg-sanity/youtube-mime.toml
2022-11-08 06:38:07 +00:00
[replace]
urls = [ "youtube.com", "youtu.be" ]
[with]
mime = "video/vnd.youtube.yt"
```
and here's what a replace extension looks like:
```
2022-11-08 06:48:56 +00:00
$ cat $XDG_DATA_HOME/xdg-sanity/youtube-replace.toml
2022-11-08 06:38:07 +00:00
[replace]
urls = [ "youtube.com", "youtu.be" ]
[with]
url = "https://piped.mint.lgbt/"
2023-03-22 17:49:02 +00:00
```