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 --- scripts/nlay/nlay | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/nlay/nlay.1 | 37 ++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100755 scripts/nlay/nlay create mode 100644 scripts/nlay/nlay.1 (limited to 'scripts/nlay') 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