Compare commits
No commits in common. "1ceacc5b22bbda4126bd357d56b9c71778b932c8" and "2450c5828994753cb0501603e3f07ff2cf742d2b" have entirely different histories.
1ceacc5b22
...
2450c58289
1 changed files with 10 additions and 18 deletions
28
uoeia
28
uoeia
|
@ -5,27 +5,27 @@ show_usage() {
|
||||||
|
|
||||||
Usage: uoeia [OPTION]... [FILE|URL]
|
Usage: uoeia [OPTION]... [FILE|URL]
|
||||||
|
|
||||||
Displays the specified image using your preferred image viewer.
|
Displays the specified image using the nsxiv program, or an image viewer of your choice.
|
||||||
|
|
||||||
Can open remote urls of individual images, galleries, as well as local files at the same time.
|
Can open remote urls of individual images, galleries, as well as local files at the same time.
|
||||||
Uses gallery-dl for remote gallery opening - so if gallery-dl can open it, so can your image viewer.
|
Uses gallery-dl for remote gallery opening - so if gallery-dl can open it, so can your image viewer.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-v, --viewer Specify the image viewer to use.
|
-v, --viewer Specify the image viewer to use (default: nsxiv).
|
||||||
-q, --quiet Don't display any output during normal operation.
|
-q, --quiet Don't display any output during normal operation.
|
||||||
-g, --gdlopts Pass through options to gallery-dl. Take care to fully quote each passed option.
|
-g, --gdlopts Pass through options to gallery-dl. Take care to fully quote each passed option.
|
||||||
-r, --replace Url patterns to replace in the format 'mypattern:::myreplacement'
|
-r, --replace Url patterns to replace in the format 'mypattern:::myreplacement'
|
||||||
-h, --help Show this help message and exit.
|
-h, --help Show this help message and exit.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
uoeia my-image.jpg Display a local image file.
|
uoeia my-image.jpg Display a local image file using nsxiv.
|
||||||
|
|
||||||
uoeia https://example.com/image Display an image/image gallery from a URL.
|
uoeia https://example.com/image Display an image/image gallery from a URL using nsxiv.
|
||||||
|
|
||||||
uoeia -v imv https://example.com/image Display an image from a URL using imv.
|
uoeia -v imv https://example.com/image Display an image from a URL using imv.
|
||||||
|
|
||||||
uoeia -g \"--range 1-10\" https://reddit.com/r/earthporn
|
uoeia -g \"--range 1-10\" https://reddit.com/r/earthporn
|
||||||
Download and display the first 10 results.
|
Download and display the first 10 results using nsxiv.
|
||||||
|
|
||||||
uoeia -r 'nitter.net:::twitter.com' https://nitter.net/donttrythis/
|
uoeia -r 'nitter.net:::twitter.com' https://nitter.net/donttrythis/
|
||||||
Display images from twitter directly instead of its
|
Display images from twitter directly instead of its
|
||||||
|
@ -33,6 +33,9 @@ Examples:
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache_dir="$(mktemp -d)"
|
||||||
|
imageviewer=nsxiv
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
[ -n "$1" ] && printf '%s\n' "$*" >&2
|
[ -n "$1" ] && printf '%s\n' "$*" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -85,19 +88,11 @@ dereference() {
|
||||||
echo "$output"
|
echo "$output"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_imageviewer() {
|
|
||||||
for cmd in nsxiv sxiv feh imv vimiv; do
|
|
||||||
if command -v "$cmd" 1>/dev/null 2>&1; then program="$cmd"; break; fi
|
|
||||||
done
|
|
||||||
echo "$program"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[ -n "$imageviewer" ] || die "Error: Could not find a suitable image viewer, set one manually with the '-v' option."
|
command -v "${imageviewer}" 1>/dev/null 2>&1 || die "Opening images in ${imageviewer} requires ${imageviewer} to be installed and and on the path."
|
||||||
command -v "${imageviewer}" 1>/dev/null 2>&1 || die "Error: Opening images in ${imageviewer} requires ${imageviewer} to be installed and and on the path."
|
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die "Error: Can not create cache directory {$cache_dir}"
|
[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die
|
||||||
im_number=1
|
im_number=1
|
||||||
while [ -n "$1" ]; do
|
while [ -n "$1" ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -112,11 +107,8 @@ main() {
|
||||||
${imageviewer} "$cache_dir"
|
${imageviewer} "$cache_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_dir="$(mktemp -d)"
|
|
||||||
imageviewer="$(get_imageviewer)"
|
|
||||||
gal_args=()
|
gal_args=()
|
||||||
replacements=()
|
replacements=()
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
|
|
Loading…
Reference in a new issue