Compare commits

6 Commits

Author SHA1 Message Date
439ef97f29 Merge pull request 'Updating README' (#10) from readme into main
Reviewed-on: #10
2022-09-22 02:05:15 +00:00
a10f4a3ceb added more readme info 2022-09-21 22:03:02 -04:00
e11e73d8a6 updated README.md 2022-09-07 22:06:14 -04:00
ffcf3ad4b0 Merge pull request 'Add redirect handling' (#9) from redirects into main
Reviewed-on: #9
2022-09-06 01:36:39 +00:00
1f912360e7 added redirect handling 2022-09-05 21:33:31 -04:00
fecb5e103e Merge pull request 'Implement Extensions' (#5) from extensions into main
Reviewed-on: #5
2022-09-05 01:05:10 +00:00
3 changed files with 37 additions and 7 deletions

View File

@@ -1,9 +1,34 @@
# xdg-sanity
This 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 settings
and sends it to the appropriate application. For example, it will send
image/jpeg MIME type files to your image viewer.
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
send `image/jpeg` MIME type files to your image viewer.
Add your default web browser to `/etc/xdg-sanity.conf` so the script can forward
links to it.
## Installation
### Arch
I maintain a package [on the
AUR](https://aur.archlinux.org/packages/xdg-sanity).
### From Source
First, make sure you have `curl(1)` and `handlr(1)` installed. Then, clone this
repository and move the `xdg-sanity/` folder into `/etc` and `xdg-sanity.sh` to
`xdg-sanity` wherever your operating system stores locally-installed binaries.
This is usually `/usr/local/bin`. Make sure the installation location is in your
`$PATH`.
Create a `xdg-sanity.desktop` file either manually or with `gendesk(1)`,
placing it, also, where your OS stores locally-installed `.desktop` files,
usually `/usr/local/applications`. Set your default web browser to that
`.desktop` file.
Add your default web browser to `/etc/xdg-sanity/xdg-sanity.conf` so the
script can forward links to it.
### Usage
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.

View File

@@ -51,7 +51,9 @@ done
if [ "$MIME" = "" ] || [ "$MIME" = "$1" ] || [ "$MIME" = "$INPUT" ]
then
echo "Determining MIME type of $INPUT:"
MIME=$(curl -I -s "$INPUT" | sed -ne 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//g' | tr -d '\r')
# Determines HTTP code, might use for something else?
# CODE=$(curl -fLIs "$INPUT" | sed -ne 's/ [[:space:]]*$//p' | sed -ne 's|^HTTP/.\+ ||p')
MIME=$(curl -fLIs "$INPUT" | sed -ne 's/^[cC]ontent-[tT]ype: //p' | sed -e 's/;.\+//p' | tail -n1 | tr -d '\r')
echo $MIME
fi

View File

@@ -0,0 +1,3 @@
# EXT-TYPE=replace
replace youtube.com or youtu.be with piped.mint.lgbt