aboutsummaryrefslogtreecommitdiffstats
path: root/community/nnn
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2018-04-03 00:41:24 +0200
committerJakub Jirutka <jakub@jirutka.cz>2018-04-03 00:44:47 +0200
commite25c15766f5a036de0fc7290cba7b98ef41b46ec (patch)
tree7dec8170db73d5e18cb14f3482153d6f72086ae2 /community/nnn
parent118a78fe94b503a7e21c98c71fc0e6c3d76373e3 (diff)
downloadaports-e25c15766f5a036de0fc7290cba7b98ef41b46ec.tar.bz2
aports-e25c15766f5a036de0fc7290cba7b98ef41b46ec.tar.xz
community/nnn: move from testing
Diffstat (limited to 'community/nnn')
-rw-r--r--community/nnn/APKBUILD32
-rw-r--r--community/nnn/nlay78
2 files changed, 110 insertions, 0 deletions
diff --git a/community/nnn/APKBUILD b/community/nnn/APKBUILD
new file mode 100644
index 0000000000..421a1b8928
--- /dev/null
+++ b/community/nnn/APKBUILD
@@ -0,0 +1,32 @@
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=nnn
+pkgver=1.7
+pkgrel=1
+pkgdesc="The missing terminal file browser for X"
+url="https://github.com/jarun/nnn"
+arch="all !armhf" # armhf: fails to build
+license="BSD-2-Clause"
+makedepends="ncurses-dev readline-dev"
+options="!check" # no tests provided and `nnn -v` requires tty
+subpackages="$pkgname-doc"
+source="$pkgname-$pkgver.tar.gz::https://github.com/jarun/$pkgname/archive/v$pkgver.tar.gz
+ nlay"
+builddir="$srcdir/$pkgname-$pkgver"
+
+build() {
+ cd "$builddir"
+ make
+}
+
+package() {
+ cd "$builddir"
+
+ make install DESTDIR="$pkgdir" PREFIX=/usr
+
+ # Overwrite the provided nlay script with our POSIX compliant version.
+ install -m 755 "$srcdir"/nlay "$pkgdir"/usr/bin/nlay
+}
+
+sha512sums="7574971b423a1c49e2217d5e4415a69536b807587b4e32b61568ce0c6a1734ed85924a3ef68027653f1f0e882ef8df1bc375e119a9ded51e133a2adf5cd560cb nnn-1.7.tar.gz
+9f70f5fec2799caf1624e1334e687072dde94ee550a4cd7ee5a1a6b9b880f3fe40b6cbd631ce2d024cb811b5115249e7cd81c880c88f2289f627cd866fc06036 nlay"
diff --git a/community/nnn/nlay b/community/nnn/nlay
new file mode 100644
index 0000000000..3d6297f192
--- /dev/null
+++ b/community/nnn/nlay
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# #############################################################################
+# nlay: a customizable script to play files in different apps by file type
+#
+# usage: nlay file type
+#
+# MUST READ:
+#
+# 1. Feel free to change the default apps to your favourite ones.
+# Simple use 'run_fg' or 'run_bg' to run the specified app with the given
+# options in foreground or background respectively. Variable '$1' contains
+# path of the file to open. If run_bg is used the app is detached and
+# started in the background in silent mode. If the app is not installed
+# (i.e. is not on your PATH), it is silently skipped and the script tries
+# next 'run_bg' or 'run_fg'.
+#
+# The 'run_bg' vs. 'run_fg' depends on personal preference and type of app,
+# e.g., I would start vim (CLI) in the foreground but Sublime Text (GUI) in
+# the background.
+#
+# 2. Detached apps are not killed when nnn exits. Use kill(1) or killall(1) to
+# 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.
+#
+# Please note that this is not the original nlay script, but Alpine version
+# rewritten to be compatible with any POSIX compliant shell, not just Bash/ZSH.
+#
+# #############################################################################
+
+# Runs the command in foreground if exists.
+run_fg() {
+ which "$1" >/dev/null && "$@"
+ exit 0
+}
+
+# Runs the command in background if exists.
+run_bg() {
+ which "$1" >/dev/null \
+ && "$@" >/dev/null 2>&1 & \
+ && exit 0
+}
+
+# Enable the lines below to handle file by extension
+# This is provided for using a custom player for specific files
+# $ext holds the extension
+<<ENABLE_FILE_TYPE_HANDLING
+fname=$(basename "$1")
+case "$fname" in
+ *.*) ;;
+ *) exit 1;;
+esac
+
+ext="${fname##*.}"
+[ -n "$ext" ] || exit 1
+ext=$(printf %s "$ext" | tr '[A-Z]' '[a-z]')
+
+# handle this extension and exit
+ENABLE_FILE_TYPE_HANDLING
+
+
+#------------ PLAINTEXT (UNUSED) ------------
+if [ "$2" = "text" ]; then
+ run_fg vim "$1"
+
+#----------------- SEARCH -------------------
+elif [ "$2" = "search" ]; then
+ run_bg gnome-search-tool --path "$1"
+ run_bg catfish --path "$1"
+
+#--------------- SCREENSAVER ----------------
+elif [ "$2" = "screensaver" ]; then
+ run_fg vlock
+fi