2022-09-02 00:42:26 -06:00
|
|
|
# xdg-sanity
|
|
|
|
|
2022-09-07 20:06:14 -06: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-21 20:03:02 -06:00
|
|
|
send `image/jpeg` MIME type files to your image viewer.
|
2022-09-02 00:42:26 -06:00
|
|
|
|
2022-09-07 20:06:14 -06:00
|
|
|
## Installation
|
|
|
|
|
2022-11-07 23:16:23 -07:00
|
|
|
### Arch Linux
|
2022-09-07 20:06:14 -06:00
|
|
|
|
|
|
|
I maintain a package [on the
|
|
|
|
AUR](https://aur.archlinux.org/packages/xdg-sanity).
|
|
|
|
|
|
|
|
### From Source
|
|
|
|
|
2022-11-07 23:38:07 -07:00
|
|
|
Dependencies:
|
|
|
|
- `curl(1)`
|
|
|
|
- `xdg-utils(1)` or `handlr(1)`
|
|
|
|
- `tomcat(1)`
|
|
|
|
|
|
|
|
You can get `tomcat` [here](https://git.tebibyte.media/emma/tomcat)
|
|
|
|
|
|
|
|
Instructions:
|
|
|
|
Clone this repository and move the `xdg-sanity` binary wherever your operating
|
|
|
|
system stores locally-installed binaries. This is usually `/usr/local/bin` or
|
2022-11-07 23:16:23 -07:00
|
|
|
`$HOME/.local/bin` for your user. Make sure the installation location is in your
|
2022-09-21 20:03:02 -06:00
|
|
|
`$PATH`.
|
2022-09-07 20:06:14 -06:00
|
|
|
|
2022-11-07 23:16:23 -07:00
|
|
|
Create an `xdg-sanity.desktop` file either manually or with `gendesk(1)`,
|
2022-11-07 23:38:07 -07:00
|
|
|
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 with
|
|
|
|
`xdg-settings(1)` or an equivalent.
|
|
|
|
|
|
|
|
### Configuration
|
2022-09-07 20:06:14 -06:00
|
|
|
|
2022-11-07 23:38:07 -07:00
|
|
|
This program uses [TOML](https://toml.io/en/v1.0.0) for its configuration. The
|
|
|
|
configuration file is set up like this:
|
|
|
|
```
|
|
|
|
$ cat $XDG_CONFIG_HOME/xdg-sanity.toml
|
|
|
|
[tools]
|
|
|
|
browser = "firefox"
|
|
|
|
xdg = "handlr launch"
|
|
|
|
```
|
|
|
|
|
|
|
|
The options available for `xdg` are `handlr launch` if you use `handlr(1)` and
|
|
|
|
`xdg-open` if you use `xdg-utils(1)`.
|
2022-09-21 20:03:02 -06:00
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
2022-11-07 23:16:23 -07:00
|
|
|
`xdg-sanity [RESOURCE]`
|
|
|
|
|
2022-09-21 20:03:02 -06:00
|
|
|
Open links from applications outside your web browser as normal. Alternatively,
|
2022-11-07 23:16:23 -07:00
|
|
|
you can call `xdg-sanity` directly with the only argument accepted being a URI.
|
2022-11-07 23:38:07 -07:00
|
|
|
|
|
|
|
#### Extensions
|
|
|
|
|
|
|
|
Extensions are written using TOML and are stored in either
|
|
|
|
`/usr/share/xdg-sanity` when installed from a package manager,
|
|
|
|
`/usr/local/share/xdg-sanity` when installed locally, or
|
|
|
|
`$XDG_DATA_HOME/xdg-sanity` for your user.
|
|
|
|
|
|
|
|
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-07 23:48:56 -07:00
|
|
|
$ cat $XDG_DATA_HOME/xdg-sanity/youtube-mime.toml
|
2022-11-07 23:38:07 -07:00
|
|
|
[replace]
|
|
|
|
urls = [ "youtube.com", "youtu.be" ]
|
|
|
|
|
|
|
|
[with]
|
|
|
|
mime = "video/vnd.youtube.yt"
|
|
|
|
```
|
|
|
|
and here's what a replace extension looks like:
|
|
|
|
```
|
2022-11-07 23:48:56 -07:00
|
|
|
$ cat $XDG_DATA_HOME/xdg-sanity/youtube-replace.toml
|
2022-11-07 23:38:07 -07:00
|
|
|
[replace]
|
|
|
|
urls = [ "youtube.com", "youtu.be" ]
|
|
|
|
|
|
|
|
[with]
|
|
|
|
url = "https://piped.mint.lgbt/"
|