Total rewrite #15
							
								
								
									
										70
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								README.md
									
									
									
									
									
								
							@ -14,21 +14,38 @@ AUR](https://aur.archlinux.org/packages/xdg-sanity).
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
### From Source
 | 
					### From Source
 | 
				
			||||||
 | 
					
 | 
				
			||||||
First, make sure you have `curl(1)`, `xdg-utils(1)` (or an alternative like
 | 
					Dependencies:
 | 
				
			||||||
[handlr](https://github.com/chmln/handlr)), and
 | 
					- `curl(1)`
 | 
				
			||||||
[tomcat](https://git.tebibyte.media/emma/tomcat) installed. Then, clone this
 | 
					- `xdg-utils(1)` or `handlr(1)`
 | 
				
			||||||
repository and move the `xdg-sanity` binary wherever your operating system
 | 
					- `tomcat(1)`
 | 
				
			||||||
stores locally-installed binaries. This is usually `/usr/local/bin` or
 | 
					
 | 
				
			||||||
 | 
					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
 | 
				
			||||||
`$HOME/.local/bin` for your user. Make sure the installation location is in your
 | 
					`$HOME/.local/bin` for your user. Make sure the installation location is in your
 | 
				
			||||||
`$PATH`.
 | 
					`$PATH`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Create an `xdg-sanity.desktop` file either manually or with `gendesk(1)`,
 | 
					Create an `xdg-sanity.desktop` file either manually or with `gendesk(1)`,
 | 
				
			||||||
placing it, also, where your OS stores locally-installed `.desktop` files,
 | 
					placing it where your OS stores locally-installed `.desktop` files, which is
 | 
				
			||||||
usually `/usr/local/applications`. Set your default web browser to that
 | 
					usually `/usr/local/share/applications` or `$XDG_DATA_HOME/applications` for 
 | 
				
			||||||
`.desktop` file with `xdg-settings(1)` or an equivalent.
 | 
					your user. Set your default web browser to that `.desktop` file with
 | 
				
			||||||
 | 
					`xdg-settings(1)` or an equivalent.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Add your default web browser to `$XDG_CONFIG_HOME/xdg-sanity.toml` so the
 | 
					### Configuration
 | 
				
			||||||
script can forward links to it.
 | 
					
 | 
				
			||||||
 | 
					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)`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Usage
 | 
					### Usage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -36,3 +53,36 @@ script can forward links to it.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Open links from applications outside your web browser as normal. Alternatively,
 | 
					Open links from applications outside your web browser as normal. Alternatively,
 | 
				
			||||||
you can call `xdg-sanity` directly with the only argument accepted being a URI.
 | 
					you can call `xdg-sanity` directly with the only argument accepted being a URI.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#### 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:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					cat $XDG_DATA_HOME/xdg-sanity/youtube-mime.toml
 | 
				
			||||||
 | 
					[replace]
 | 
				
			||||||
 | 
					urls = [ "youtube.com", "youtu.be" ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[with]
 | 
				
			||||||
 | 
					mime = "video/vnd.youtube.yt"
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					and here's what a replace extension looks like:
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					cat $XDG_DATA_HOME/xdg-sanity/youtube-replace.toml
 | 
				
			||||||
 | 
					[replace]
 | 
				
			||||||
 | 
					urls = [ "youtube.com", "youtu.be" ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[with] 
 | 
				
			||||||
 | 
					url = "https://piped.mint.lgbt/"
 | 
				
			||||||
 | 
				
			|||||||
@ -68,6 +68,7 @@ while test -n "$1"; do
 | 
				
			|||||||
	for file in \
 | 
						for file in \
 | 
				
			||||||
		"$XDG_DATA_HOME"/xdg-sanity/*-mime.toml \
 | 
							"$XDG_DATA_HOME"/xdg-sanity/*-mime.toml \
 | 
				
			||||||
	  /usr/share/xdg-sanity/*-mime.toml \
 | 
						  /usr/share/xdg-sanity/*-mime.toml \
 | 
				
			||||||
 | 
							/usr/local/share/xdg-sanity/*-mime.toml \
 | 
				
			||||||
		/dev/null
 | 
							/dev/null
 | 
				
			||||||
	do
 | 
						do
 | 
				
			||||||
		i=$(tomcat replace.urls "$file" | sed 's/	/\n/g' | xargs wc -l)
 | 
							i=$(tomcat replace.urls "$file" | sed 's/	/\n/g' | xargs wc -l)
 | 
				
			||||||
@ -83,6 +84,7 @@ while test -n "$1"; do
 | 
				
			|||||||
	for file in \
 | 
						for file in \
 | 
				
			||||||
		"$XDG_DATA_HOME"/xdg-sanity/*-replace.toml \
 | 
							"$XDG_DATA_HOME"/xdg-sanity/*-replace.toml \
 | 
				
			||||||
	  /usr/share/xdg-sanity/*-replace.toml \
 | 
						  /usr/share/xdg-sanity/*-replace.toml \
 | 
				
			||||||
 | 
							/usr/local/share/xdg-sanity/*-replace.toml \
 | 
				
			||||||
		/dev/null
 | 
							/dev/null
 | 
				
			||||||
	do
 | 
						do
 | 
				
			||||||
    i=$(tomcat replace.urls "$file" | sed 's/	/\n/g' | xargs wc -l)
 | 
					    i=$(tomcat replace.urls "$file" | sed 's/	/\n/g' | xargs wc -l)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user