aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-11 01:49:40 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-06-11 01:49:40 +0530
commit0f67e1ff7dcda0bf9023579e86abd9808e770b3a (patch)
tree552f03fc1c45edf014bc09714e269d083b663daa /plugins
parenta103f513c38329dcf22fd73f34b1117156f391ae (diff)
downloadnnn-0f67e1ff7dcda0bf9023579e86abd9808e770b3a.tar.gz
support imv in imgview and nuke
Diffstat (limited to 'plugins')
-rw-r--r--plugins/README.md2
-rwxr-xr-xplugins/imgview24
-rwxr-xr-xplugins/nuke18
3 files changed, 29 insertions, 15 deletions
diff --git a/plugins/README.md b/plugins/README.md
index 86429d9..841c6b8 100644
--- a/plugins/README.md
+++ b/plugins/README.md
@@ -45,7 +45,7 @@ Plugins are installed to `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins`.
| [imgresize](imgresize) | Resize images in dir to screen resolution | sh | [imgp](https://github.com/jarun/imgp) |
| [imgthumb](imgthumb) | View thumbnail of an image or dir of images | sh | [lsix](https://github.com/hackerb9/lsix) |
| [imgur](imgur) | Upload an image to imgur (from [imgur-screenshot](https://github.com/jomo/imgur-screenshot)) | bash | - |
-| [imgview](imgview) | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | sxiv/[viu](https://github.com/atanunq/viu), less|
+| [imgview](imgview) | Browse images, set wallpaper, copy path ([config](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)), [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images)| sh | [imv](https://github.com/eXeC64/imv)/[sxiv](https://github.com/muennich/sxiv)/[viu](https://github.com/atanunq/viu), less|
| [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois |
| [kdeconnect](kdeconnect) | Send selected files to an Android device | sh | kdeconnect-cli |
| [launch](launch) | GUI application launcher | sh | fzf |
diff --git a/plugins/imgview b/plugins/imgview
index 9370ae5..d221f98 100755
--- a/plugins/imgview
+++ b/plugins/imgview
@@ -2,6 +2,9 @@
# Description: Open images in hovered directory and thumbnails
# open hovered image in sxiv or viu and browse other images in the directory
+# Dependencies: imv (https://github.com/eXeC64/imv) or,
+# sxiv (https://github.com/muennich/sxiv) or,
+# viu (https://github.com/atanunq/viu), less
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
@@ -18,14 +21,15 @@ listimages() {
'.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}
-sxiv_view_dir() {
- target="$(abspath "$1")"
+view_dir() {
+ target="$(abspath "$2")"
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
if [ -n "$count" ]; then
- listimages | xargs -0 sxiv -n "$count" --
+ listimages | xargs -0 "$1" -n "$count" --
else
- sxiv -- "$@" # fallback
+ shift
+ "$1" -- "$@" # fallback
fi
}
@@ -35,16 +39,22 @@ if [ -z "$1" ] || ! [ -s "$1" ]; then
exit 1
fi
-if command -v sxiv >/dev/null 2>&1; then
+if command -v imvr >/dev/null 2>&1; then
if [ -f "$1" ]; then
- sxiv_view_dir "$1" >/dev/null 2>&1 &
+ view_dir imvr "$1" >/dev/null 2>&1 &
+ elif [ -d "$1" ] || [ -h "$1" ]; then
+ imvr "$1" >/dev/null 2>&1 &
+ fi
+elif command -v sxiv >/dev/null 2>&1; then
+ if [ -f "$1" ]; then
+ view_dir sxiv "$1" >/dev/null 2>&1 &
elif [ -d "$1" ] || [ -h "$1" ]; then
sxiv -qt "$1" >/dev/null 2>&1 &
fi
elif command -v viu >/dev/null 2>&1; then
viu -n "$1" | less -R
else
- printf "install sxiv or viu"
+ printf "install imv/sxiv/viu"
read -r _
exit 2
fi
diff --git a/plugins/nuke b/plugins/nuke
index 39c6324..30cfe7a 100755
--- a/plugins/nuke
+++ b/plugins/nuke
@@ -51,7 +51,7 @@
# htm|html|xhtml: w3m, lynx, elinks
# json: jq, python (json.tool module)
# Multimedia by mime:
-# image/*: sxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool
+# image/*: imv/sxiv (GUI), viu (https://github.com/atanunq/viu), img2txt, exiftool
# video/*: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool
# audio/*: mocplay (nnn plugin using MOC), mpv, mediainfo, exiftool
# application/pdf: zathura (GUI), pdftotext, mutool, exiftool
@@ -257,14 +257,15 @@ listimages() {
'.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}
-sxiv_load_dir() {
- target="$(abspath "$1")"
+load_dir() {
+ target="$(abspath "$2")"
count="$(listimages | grep -a -m 1 -ZznF "$target" | cut -d: -f1)"
if [ -n "$count" ]; then
- listimages | xargs -0 sxiv -n "$count" --
+ listimages | xargs -0 "$1" -n "$count" --
else
- sxiv -- "$@" # fallback
+ shift
+ "$1" -- "$@" # fallback
fi
}
@@ -290,8 +291,11 @@ handle_multimedia() {
## Image
image/*)
- if [ "$GUI" -ne 0 ] && which sxiv >/dev/null 2>&1; then
- sxiv_load_dir "${FPATH}" >/dev/null 2>&1 &
+ if [ "$GUI" -ne 0 ] && which imvr >/dev/null 2>&1; then
+ load_dir imvr "${FPATH}" >/dev/null 2>&1 &
+ exit 0
+ elif [ "$GUI" -ne 0 ] && which sxiv >/dev/null 2>&1; then
+ load_dir sxiv "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which viu >/dev/null 2>&1; then
viu -n "${FPATH}" | eval "$PAGER"