]> Sergey Matveev's repositories - nnn.git/commitdiff
nlay - support multiple apps
authorArun Prakash Jana <engineerarun@gmail.com>
Mon, 5 Jun 2017 04:54:28 +0000 (10:24 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Mon, 5 Jun 2017 15:36:52 +0000 (21:06 +0530)
README.md
nlay
nnn.1
nnn.c

index 3644a9645b7383957f2872423accdc4df4890f83..def02e4ecb8f3d7aa0b1784c57dca9404ddc1382 100644 (file)
--- a/README.md
+++ b/README.md
@@ -47,7 +47,7 @@ Noice is Not Noice, a noicer fork...
 
 `nnn` is a fork of [noice](http://git.2f30.org/noice/), a blazing-fast lightweight terminal file browser with easy keyboard shortcuts for navigation, opening files and running tasks. noice is developed considering terminal based systems. There is no config file and mime associations are hard-coded. However, the incredible user-friendliness and speed make it a perfect utility on modern distros.
 
-`nnn` can use the default desktop opener at runtime and handle media types with `nlay`, a customizable bash script. `nnn` adds new navigation options, [navigate-as-you-type](#navigate-as-you-type-mode) mode, enhanced DE integration, a disk usage analyzer mode, comprehensive file details and much more. Add to that a huge [performance](#performance) boost. For a detailed comparison, visit [nnn vs. noice](https://github.com/jarun/nnn/wiki/nnn-vs.-noice).
+`nnn` can use the default desktop opener at runtime and handle media types with [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay), a customizable bash script. `nnn` adds new navigation options, [navigate-as-you-type](#navigate-as-you-type-mode) mode, enhanced DE integration, a disk usage analyzer mode, comprehensive file details and much more. Add to that a huge [performance](#performance) boost. For a detailed comparison, visit [nnn vs. noice](https://github.com/jarun/nnn/wiki/nnn-vs.-noice).
 
 If you want to edit a file in vim with some soothing music in the background while referring to a spec in your GUI PDF viewer, `nnn` got it! All from the same terminal session. Follow the instructions in the [quickstart](#quickstart) section and see how `nnn` simplifies those long desktop sessions...
 
@@ -164,7 +164,7 @@ Right, Enter, l, ^M | Open file or enter dir
                   & | Jump to initial dir
                   - | Jump to last visited dir
                   / | Filter dir contents
-                 ^/ | Search dir in gnome-search-tool
+                 ^/ | Search dir in desktop search tool
                   . | Toggle hide .dot files
                   c | Show change dir prompt
                   d | Toggle detail view
@@ -223,10 +223,10 @@ The following abbreviations are used in the detail view:
         export NNN_OPENER=gvfs-open
   - If `nnn` recognizes the file extension, it invokes nlay (which invokes the players). Default apps:
     - mpv - audio and video
-    - viewnior - image
+    - viewnior, fim - image
     - [zathura](https://pwmt.org/projects/zathura/) - pdf
     - vim - plain text
-    - gnome-search-tool - search
+    - gnome-search-tool, catfish - search
     - vlock - terminal screensaver
     - to add, remove recognized extensions in `nnn`, see [how to change file associations](#change-file-associations)
   - If a file without any extension is a plain text file, it is opened in EDITOR (fallback vi)
diff --git a/nlay b/nlay
index 06859952ce26493e86d8eb11b51e85240d9efbe8..04dc4642a840b4ff3b544e6f357c20378c65438a 100755 (executable)
--- a/nlay
+++ b/nlay
@@ -8,9 +8,9 @@
 # MUST READ:
 #
 # 1. Feel free to change the default apps to your favourite ones.
-#    If you change the app for a group you may also need to modify the bg
-#    setting. If bg is set the app is detached and started in the background in
-#    silent mode.
+#    If you change the app for a group you may also need to modify the opts and
+#    bg settings. If bg is set the app is detached and started in the background
+#    in silent mode.
 #
 #    The bg setting depends on personal preference and type of app, e.g.,
 #    I would start vim (CLI) in the foreground but Sublime Text (GUI) in the
@@ -59,6 +59,7 @@ ENABLE_FILE_TYPE_HANDLING
 #------------------ AUDIO -------------------
 if [ "$2" == "audio" ]; then
     app=mpv
+
     # To start mpv in a window enable opts
     #opts="--no-terminal --force-window"
 
@@ -70,11 +71,11 @@ if [ "$2" == "audio" ]; then
 
     eval $app $opts "\"$1\"" $bg
     exit 0
-fi
 
 #------------------ VIDEO -------------------
-if [ "$2" == "video" ]; then
+elif [ "$2" == "video" ]; then
     app=mpv
+
     # To start mpv in a window enable opts
     #opts="--no-terminal --force-window"
 
@@ -86,59 +87,61 @@ if [ "$2" == "video" ]; then
 
     eval $app $opts "\"$1\"" $bg
     exit 0
-fi
 
 #------------------ IMAGE -------------------
-if [ "$2" == "image" ]; then
-    app=viewnior
-    #opts=
+elif [ "$2" == "image" ]; then
+    app=("viewnior"
+         "fim")
 
-    bg=">/dev/null 2>&1 &"
+    opts=(""
+          "-a --cd-and-readdir")
 
-    eval $app $opts "\"$1\"" $bg
-    exit 0
-fi
+    bg=(">/dev/null 2>&1 &"
+        ">/dev/null 2>&1 &")
 
 #------------------- PDF --------------------
-if [ "$2" == "pdf" ]; then
-    app=zathura
-    #opts=
+elif [ "$2" == "pdf" ]; then
+    app=("zathura")
 
-    bg=">/dev/null 2>&1 &"
+    opts=("")
 
-    eval $app $opts "\"$1\"" $bg
-    exit 0
-fi
+    bg=(">/dev/null 2>&1 &")
 
 #---------------- PLAINTEXT -----------------
-if [ "$2" == "text" ]; then
-    app=vim
-    #opts=
+elif [ "$2" == "text" ]; then
+    app=("vim")
 
-    #bg=">/dev/null 2>&1 &"
+    opts=("")
 
-    eval $app $opts "\"$1\"" $bg
-    exit 0
-fi
+    bg=("")
 
 #----------------- SEARCH -------------------
-if [ "$2" == "search" ]; then
-    app=gnome-search-tool
-    #opts=
+elif [ "$2" == "search" ]; then
+    app=("gnome-search-tool"
+         "catfish")
 
-    bg=">/dev/null 2>&1 &"
+    opts=(""
+          "--path")
 
-    eval $app $opts --path "\"$1\"" $bg
-    exit 0
-fi
+    bg=(">/dev/null 2>&1 &"
+        ">/dev/null 2>&1 &")
 
 #--------------- SCREENSAVER ----------------
-if [ "$2" == "screensaver" ]; then
+elif [ "$2" == "screensaver" ]; then
     app=vlock
+
     #opts=
 
     #bg=">/dev/null 2>&1 &"
 
+    type -P $app &>/dev/null &&
     eval $app $opts $bg
     exit 0
 fi
+
+#------------------- PLAY -------------------
+for index in ${!app[@]}
+do
+    type -P ${app[$index]} &>/dev/null &&
+    eval ${app[$index]} ${opts[$index]} "\"$1\"" ${bg[$index]}
+done
diff --git a/nnn.1 b/nnn.1
index 4b4bbd0c48da43d0419b31732f6929641f9d405e..95c0ec8c195066aeebbe99c4830d6247056c1157 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -54,7 +54,7 @@ Change to the last visited directory
 .It Ic /
 Change filter (more information below)
 .It Ic ^/
-Search directory in gnome-search-tool
+Search directory in desktop search tool
 .It Ic \&.
 Toggle hide .dot files
 .It Ic c
diff --git a/nnn.c b/nnn.c
index 1b3aadb9fa8f9bd67ea6cce8918b8973a7280361..ec9fce0b8626c1f79a1a9b57214449d171521fe3 100644 (file)
--- a/nnn.c
+++ b/nnn.c
@@ -1259,7 +1259,7 @@ show_help(void)
                     & | Jump to initial dir\n\
                     - | Jump to last visited dir\n\
                     / | Filter dir contents\n\
-                   ^/ | Search dir in gnome-search-tool\n\
+                   ^/ | Search dir in desktop search tool\n\
                     . | Toggle hide .dot files\n\
                     c | Show change dir prompt\n\
                     d | Toggle detail view\n\