scripts: Change nxsiv-rifle to uoeia
I rewrote and extended the nsxiv-rifle script recently, and this change now: removes the old script, adds the new one as a submodule into the repository and links a working binary into the path. The new script is essentially still just an image grabber-and-opener, but supports more image viewers, is a little more advanced and can for example replace arbitrary parts of urls (and is documented a little more nicely). Make qutebrowser use new script and remove leftover references to nsxiv-rifle. Qutebrowser also gets a third option of viewing images, now there are: ,i -> open selected link in imageviewer ,I -> open current page in imageviewer ,<C-i> -> open selected image in imageviewer
This commit is contained in:
parent
a0b3ed6c1f
commit
8912a09a39
6 changed files with 12 additions and 90 deletions
|
|
@ -1,75 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Advanced nsxiv url opening script.
|
||||
#
|
||||
# Can open remote urls of individual images, galleries, and local files at the same time.
|
||||
# Uses gallery-dl for remote gallery opening - so if gallery-dl can open it, so can nsxiv.
|
||||
#
|
||||
# Usage: simply add multiple urls/paths as arguments.
|
||||
# nsxiv-rifle "https://linkto.my/image.png" my/local/relative-path.jpg /home/absolute.gif
|
||||
|
||||
cache_dir="$(mktemp -d)"
|
||||
|
||||
die() {
|
||||
[ -n "$1" ] && printf '%s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
rm -f -- "$cache_dir"/*
|
||||
}
|
||||
|
||||
from_local() {
|
||||
fpath="$(realpath -e "$1")"
|
||||
ln -s "$fpath" "$cache_dir"
|
||||
}
|
||||
|
||||
# invokes single image downloading or gallery downloading depending on content type
|
||||
from_remote() {
|
||||
link="$(dereference "$1")"
|
||||
if curl -sLI "$link" | grep -i '^Content-Type:' | grep -q image; then
|
||||
get_single_image "$link"
|
||||
else
|
||||
get_gallery "$link"
|
||||
fi
|
||||
}
|
||||
|
||||
get_gallery() {
|
||||
command -v gallery-dl 1>/dev/null 2>&1 || return
|
||||
gallery-dl -q -D "$cache_dir" "$1"
|
||||
}
|
||||
|
||||
get_single_image() {
|
||||
pwd="$PWD"
|
||||
cd "$cache_dir" && curl -sSLO "$1"
|
||||
cd "$pwd" || exit 1
|
||||
}
|
||||
|
||||
# unaliases urls which will not be downloaded correctly otherwise
|
||||
dereference() {
|
||||
# teddit
|
||||
if echo "$1" | grep -qe "https\?://w\?w\?w\?\.\?teddit\.net.\+"; then
|
||||
echo "$1" | sed -e 's|^.*pics/w:null_\(.\+\)$|https://i.redd.it/\1|'
|
||||
else
|
||||
echo "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
### main ###
|
||||
command -v nsxiv 1>/dev/null 2>&1 || die "Requires nsxiv installed"
|
||||
|
||||
[ -z "$1" ] && nsxiv
|
||||
trap cleanup EXIT
|
||||
[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die
|
||||
im_number=1
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
*://*.*) from_remote "$1" ;;
|
||||
*) from_local "$1" ;;
|
||||
esac
|
||||
im_number=$((im_number + 1))
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$(find -L "$cache_dir" -type f -print | wc -l)" -ne 0 ] &&
|
||||
nsxiv -p "$cache_dir"
|
||||
1
scripts/.local/bin/uoeia
Symbolic link
1
scripts/.local/bin/uoeia
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../share/uoeia/uoeia
|
||||
Loading…
Add table
Add a link
Reference in a new issue