From 497911e999d34fbb34a6abdb045afd3e6a6c2d1f Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Sat, 10 Nov 2018 12:06:21 +0530 Subject: Retire nlay --- Makefile | 10 +-- README.md | 5 +- nlay | 105 ----------------------- nlay.1 | 37 -------- nnn.1 | 13 +-- nnn.c | 33 ++++--- scripts/auto-completion/bash/nnn-completion.bash | 2 - scripts/auto-completion/fish/nnn.fish | 1 - scripts/auto-completion/zsh/_nnn | 1 - scripts/nlay/nlay | 105 +++++++++++++++++++++++ scripts/nlay/nlay.1 | 37 ++++++++ 11 files changed, 162 insertions(+), 187 deletions(-) delete mode 100755 nlay delete mode 100644 nlay.1 create mode 100755 scripts/nlay/nlay create mode 100644 scripts/nlay/nlay.1 diff --git a/Makefile b/Makefile index 60fa49e..12769c6 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,11 @@ else LDLIBS += -lncurses endif -DISTFILES = nlay nlay.1 nnn.c nnn.h nnn.1 Makefile README.md LICENSE +DISTFILES = nnn.c nnn.h nnn.1 Makefile README.md LICENSE SRC = nnn.c BIN = nnn -PLAYER = nlay -all: $(BIN) $(PLAYER) +all: $(BIN) $(SRC): nnn.h @@ -33,16 +32,13 @@ debug: $(SRC) install: all $(INSTALL) -m 0755 -d $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 0755 $(BIN) $(PLAYER) $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin $(INSTALL) -m 0755 -d $(DESTDIR)$(MANPREFIX)/man1 $(INSTALL) -m 0644 $(BIN).1 $(DESTDIR)$(MANPREFIX)/man1 - $(INSTALL) -m 0644 $(PLAYER).1 $(DESTDIR)$(MANPREFIX)/man1 uninstall: $(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN) - $(RM) $(DESTDIR)$(PREFIX)/bin/$(PLAYER) $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(BIN).1 - $(RM) $(DESTDIR)$(MANPREFIX)/man1/$(PLAYER).1 strip: $(BIN) $(STRIP) $^ diff --git a/README.md b/README.md index 973dfbb..d443b7d 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ Search keyword and option completion scripts for Bash, Fish and Zsh can be found ``` usage: nnn [-b key] [-c N] [-e] [-i] [-l] - [-p nlay] [-S] [-v] [-h] [PATH] + [-S] [-v] [-h] [PATH] The missing terminal file manager for X. @@ -197,7 +197,6 @@ optional args: -e use exiftool instead of mediainfo -i start in navigate-as-you-type mode -l start in light mode - -p nlay path to custom nlay -S start in disk usage analyser mode -v show program version -h show this help @@ -346,8 +345,6 @@ The following indicators are used in the detail view: export NNN_USE_EDITOR=1 -Customizable script [nlay](https://github.com/jarun/nnn/wiki/all-about-nlay) is used to run terminal locker. - #### Help $ nnn -h diff --git a/nlay b/nlay deleted file mode 100755 index 1930379..0000000 --- a/nlay +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash - -# ############################################################################# -# nlay: a customizable script to play files in different apps by file type -# -# usage: nlay file/path type/action -# -# 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 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 preferences and type of utility, e.g., I -# would start vi (CLI) in the foreground but Sublime Text (GUI) in background. -# -# Check (and TOGGLE as you wish) the default bg settings. -# -# 2. Detached apps are not killed when nnn exits. Use kill(1) or killall(1) to -# stop console based background apps. -# -# 3. nlay is OVERWRITTEN during nnn upgrade. You can store your custom nlay in a -# location other than the default and have an alias with nnn option '-p' to -# invoke it. Remember it might break or lack new capabilities added to nlay -# in future releases. Check the file diff once in a while. -# -# Author: Arun Prakash Jana -# Email: engineerarun@gmail.com -# Homepage: https://github.com/jarun/nnn -# Copyright © 2016-2018 Arun Prakash Jana -# ############################################################################# - - -# Enable the lines below to handle file by extension -# This is provided for using a custom player for specific files -# $ext holds the extension -</dev/null 2>&1 &" - ">/dev/null 2>&1 &") - -#--------------- SCREENSAVER ---------------- -elif [ "$2" == "screensaver" ]; then - app=("vlock" - "bashlock" - "lock") - -for index in ${!app[@]} -do - type -P ${app[$index]} &>/dev/null && - eval ${app[$index]} && - exit 0 -done - -#------------------ SCRIPT ------------------ -elif [ "$2" == "script" ]; then - # add commands or a custom script below - - # echo "my commands or custom script" - # sh "path_to_script.sh" - $SHELL "$1" - - exit 0 -fi - -#----------------- RUN APP ------------------ -for index in ${!app[@]} -do - type -P ${app[$index]} &>/dev/null && - eval ${app[$index]} ${opts[$index]} "\"$1\"" ${bg[$index]} && - break -done diff --git a/nlay.1 b/nlay.1 deleted file mode 100644 index 9df0e01..0000000 --- a/nlay.1 +++ /dev/null @@ -1,37 +0,0 @@ -.Dd Mar 14, 2018 -.Dt NLAY 1 -.Os -.Sh NAME -.Nm nlay -.Nd a bash script to play files in different apps by file type or run some actions. -.Sh SYNOPSIS -.Nm -file/path type/action -.Sh DESCRIPTION -.Nm -is shipped with \fInnn\fR to deliver a level of flexibility to users to choose their own apps when running some actions, run some commands or custom scripts. It has provisions to handle text files too. However, the capability is not used in the latest releases. Now -.Nm -is invoked to run a desktop search (\fIgnome-search-tool\fR or \fIcatfish\fR) or screen locker (\fIvlock\fR or \fIbashlock\fR or \fIlock\fR) utility. However, -.Nm -can run independently and can be highly customized for personal usage. -.Pp -.Nm -supports the following options: -.Pp -"file/path" - The first argument can be the file or path to pass as an argument to the app. It can also be an empty string e.g., while locking the terminal. -.Pp -"type/action" - This can be any of the strings \fItext\fR, \fIsearch\fR, \fIscript\fR or \fI screensaver\fR. -.Sh USAGE -.Pp -.Bd -literal -$ nlay info.txt text -$ nlay . search -$ nlay ~/script.sh script -$ nlay "" screensaver -.Ed -.Sh AUTHOR -.An Arun Prakash Jana Aq Mt engineerarun@gmail.com . -.Sh HOME -.Em https://github.com/jarun/nnn diff --git a/nnn.1 b/nnn.1 index f3b2636..82b4732 100644 --- a/nnn.1 +++ b/nnn.1 @@ -11,7 +11,6 @@ .Op Ar -e .Op Ar -i .Op Ar -l -.Op Ar -p nlay .Op Ar -S .Op Ar -v .Op Ar -h @@ -152,9 +151,6 @@ supports the following options: .Fl l start in light mode (fewer details) .Pp -.Fl "p nlay" - path to custom nlay -.Pp .Fl S start in disk usage analyzer mode .Pp @@ -165,14 +161,7 @@ supports the following options: show program help and exit .Sh CONFIGURATION .Nm -uses \fIxdg-open\fR (on Linux) and \fIopen(1)\fR (on OS X) as the desktop -opener. It invokes -.Pa nlay -to run the terminal locker. Read more on -.Pa nlay -at: -.br -.Em https://github.com/jarun/nnn/wiki/all-about-nlay +uses \fIxdg-open\fR (on Linux) and \fIopen(1)\fR (on OS X) as the desktop opener. .Pp There is no configuration file. Settings work on environment variables. Please refer to the ENVIRONMENT section below. diff --git a/nnn.c b/nnn.c index efce9b3..575f91d 100644 --- a/nnn.c +++ b/nnn.c @@ -284,7 +284,6 @@ static char *pnamebuf, *pcopybuf; static int ndents, cur, total_dents = ENTRY_INCR; static uint idle; static uint idletimeout, copybufpos, copybuflen; -static char *player; static char *copier; static char *editor; static blkcnt_t ent_blocks; @@ -322,10 +321,10 @@ static struct timespec gtimeout; #define MEDIAINFO 0 #define EXIFTOOL 1 #define OPENER 2 -#define NLAY 3 -#define ATOOL 4 -#define APACK 5 -#define VIDIR 6 +#define ATOOL 3 +#define APACK 4 +#define VIDIR 5 +#define LOCKER 6 #define UNKNOWN 7 /* Utilities to open files, run actions */ @@ -339,10 +338,16 @@ static char * const utils[] = { #else "xdg-open", #endif - "nlay", "atool", "apack", "vidir", +#ifdef __APPLE__ + "bashlock", +#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) + "lock", +#else + "vlock", +#endif "UNKNOWN" }; @@ -3282,7 +3287,7 @@ nochange: spawn(run, dents[cur].name, NULL, path, F_NORMAL); break; case SEL_LOCK: - spawn(player, "", "screensaver", NULL, F_NORMAL | F_SIGINT); + spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT); break; case SEL_QUITCTX: { @@ -3337,7 +3342,7 @@ nochange: /* Screensaver */ if (idletimeout != 0 && idle == idletimeout) { idle = 0; - spawn(player, "", "screensaver", NULL, F_NORMAL | F_SIGINT); + spawn(utils[LOCKER], NULL, NULL, NULL, F_NORMAL | F_SIGINT); } } } @@ -3346,7 +3351,7 @@ static void usage(void) { fprintf(stdout, "usage: nnn [-b key] [-c N] [-e] [-i] [-l]\n" - " [-p nlay] [-S] [-v] [-h] [PATH]\n\n" + " [-S] [-v] [-h] [PATH]\n\n" "The missing terminal file manager for X.\n\n" "positional args:\n" " PATH start dir [default: current dir]\n\n" @@ -3356,7 +3361,6 @@ static void usage(void) " -e use exiftool instead of mediainfo\n" " -i start in navigate-as-you-type mode\n" " -l start in light mode\n" - " -p nlay path to custom nlay\n" " -S start in disk usage analyser mode\n" " -v show program version\n" " -h show this help\n\n" @@ -3376,7 +3380,7 @@ int main(int argc, char *argv[]) exit(1); } - while ((opt = getopt(argc, argv, "Slib:c:ep:vh")) != -1) { + while ((opt = getopt(argc, argv, "Slib:c:evh")) != -1) { switch (opt) { case 'S': cfg.blkorder = 1; @@ -3401,9 +3405,6 @@ int main(int argc, char *argv[]) case 'e': cfg.metaviewer = EXIFTOOL; break; - case 'p': - player = optarg; - break; case 'v': fprintf(stdout, "%s\n", VERSION); return 0; @@ -3464,10 +3465,6 @@ int main(int argc, char *argv[]) editor = xgetenv("EDITOR", "vi"); } - /* Set player if not set already */ - if (!player) - player = utils[NLAY]; - /* Get screensaver wait time, if set; copier used as tmp var */ copier = getenv("NNN_IDLE_TIMEOUT"); if (copier) { diff --git a/scripts/auto-completion/bash/nnn-completion.bash b/scripts/auto-completion/bash/nnn-completion.bash index b16b296..6eaba96 100644 --- a/scripts/auto-completion/bash/nnn-completion.bash +++ b/scripts/auto-completion/bash/nnn-completion.bash @@ -16,13 +16,11 @@ _nnn () { -h -i -l - -p -S -v ) opts_with_arg=( -c - -p ) # Do not complete non option names diff --git a/scripts/auto-completion/fish/nnn.fish b/scripts/auto-completion/fish/nnn.fish index 2eebc48..47c9f8e 100644 --- a/scripts/auto-completion/fish/nnn.fish +++ b/scripts/auto-completion/fish/nnn.fish @@ -10,6 +10,5 @@ complete -c nnn -s e -d 'use exiftool instead of mediainfo' complete -c nnn -s h -d 'show this help and exit' complete -c nnn -s i -d 'start in navigate-as-you-type mode' complete -c nnn -s l -d 'start in light mode (fewer details)' -complete -c nnn -s p -r -d 'specify custom nlay' complete -c nnn -s S -d 'start in disk usage analyzer mode' complete -c nnn -s v -d 'show program version and exit' diff --git a/scripts/auto-completion/zsh/_nnn b/scripts/auto-completion/zsh/_nnn index 3ccfeb7..746dc41 100644 --- a/scripts/auto-completion/zsh/_nnn +++ b/scripts/auto-completion/zsh/_nnn @@ -14,7 +14,6 @@ args=( '(-h)-h[show this help and exit]' '(-i)-i[start in navigate-as-you-type mode]' '(-l)-l[start in light mode (fewer details)]' - '(-p)-p[specify custom nlay]:path to nlay' '(-S)-S[start in disk usage analyzer mode]' '(-v)-v[show program version and exit]' '*:filename:_files' diff --git a/scripts/nlay/nlay b/scripts/nlay/nlay new file mode 100755 index 0000000..1930379 --- /dev/null +++ b/scripts/nlay/nlay @@ -0,0 +1,105 @@ +#!/usr/bin/env bash + +# ############################################################################# +# nlay: a customizable script to play files in different apps by file type +# +# usage: nlay file/path type/action +# +# 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 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 preferences and type of utility, e.g., I +# would start vi (CLI) in the foreground but Sublime Text (GUI) in background. +# +# Check (and TOGGLE as you wish) the default bg settings. +# +# 2. Detached apps are not killed when nnn exits. Use kill(1) or killall(1) to +# stop console based background apps. +# +# 3. nlay is OVERWRITTEN during nnn upgrade. You can store your custom nlay in a +# location other than the default and have an alias with nnn option '-p' to +# invoke it. Remember it might break or lack new capabilities added to nlay +# in future releases. Check the file diff once in a while. +# +# Author: Arun Prakash Jana +# Email: engineerarun@gmail.com +# Homepage: https://github.com/jarun/nnn +# Copyright © 2016-2018 Arun Prakash Jana +# ############################################################################# + + +# Enable the lines below to handle file by extension +# This is provided for using a custom player for specific files +# $ext holds the extension +</dev/null 2>&1 &" + ">/dev/null 2>&1 &") + +#--------------- SCREENSAVER ---------------- +elif [ "$2" == "screensaver" ]; then + app=("vlock" + "bashlock" + "lock") + +for index in ${!app[@]} +do + type -P ${app[$index]} &>/dev/null && + eval ${app[$index]} && + exit 0 +done + +#------------------ SCRIPT ------------------ +elif [ "$2" == "script" ]; then + # add commands or a custom script below + + # echo "my commands or custom script" + # sh "path_to_script.sh" + $SHELL "$1" + + exit 0 +fi + +#----------------- RUN APP ------------------ +for index in ${!app[@]} +do + type -P ${app[$index]} &>/dev/null && + eval ${app[$index]} ${opts[$index]} "\"$1\"" ${bg[$index]} && + break +done diff --git a/scripts/nlay/nlay.1 b/scripts/nlay/nlay.1 new file mode 100644 index 0000000..9df0e01 --- /dev/null +++ b/scripts/nlay/nlay.1 @@ -0,0 +1,37 @@ +.Dd Mar 14, 2018 +.Dt NLAY 1 +.Os +.Sh NAME +.Nm nlay +.Nd a bash script to play files in different apps by file type or run some actions. +.Sh SYNOPSIS +.Nm +file/path type/action +.Sh DESCRIPTION +.Nm +is shipped with \fInnn\fR to deliver a level of flexibility to users to choose their own apps when running some actions, run some commands or custom scripts. It has provisions to handle text files too. However, the capability is not used in the latest releases. Now +.Nm +is invoked to run a desktop search (\fIgnome-search-tool\fR or \fIcatfish\fR) or screen locker (\fIvlock\fR or \fIbashlock\fR or \fIlock\fR) utility. However, +.Nm +can run independently and can be highly customized for personal usage. +.Pp +.Nm +supports the following options: +.Pp +"file/path" + The first argument can be the file or path to pass as an argument to the app. It can also be an empty string e.g., while locking the terminal. +.Pp +"type/action" + This can be any of the strings \fItext\fR, \fIsearch\fR, \fIscript\fR or \fI screensaver\fR. +.Sh USAGE +.Pp +.Bd -literal +$ nlay info.txt text +$ nlay . search +$ nlay ~/script.sh script +$ nlay "" screensaver +.Ed +.Sh AUTHOR +.An Arun Prakash Jana Aq Mt engineerarun@gmail.com . +.Sh HOME +.Em https://github.com/jarun/nnn -- cgit v1.2.3-70-g09d2