From 69aeeb51d249736c37ea6aa095be4ffb020731d8 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Tue, 12 Mar 2019 16:19:34 +0530 Subject: GUI app launcher with drop-down menu `nlauncher` is POSIX compliant. It needs `fzy`. --- src/nnn.c | 12 ++++++++++-- src/nnn.h | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nnn.c b/src/nnn.c index 1eed781..b5b4e08 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -394,7 +394,8 @@ static struct timespec gtimeout; #define APACK 4 #define VIDIR 5 #define LOCKER 6 -#define UNKNOWN 7 +#define NLAUNCH 7 +#define UNKNOWN 8 /* Utilities to open files, run actions */ static char * const utils[] = { @@ -417,6 +418,7 @@ static char * const utils[] = { #else "vlock", #endif + "nlaunch", "UNKNOWN" }; @@ -2385,7 +2387,7 @@ static bool show_help(const char *path) "1MISC\n" "9! ^] Spawn SHELL C Execute entry\n" "9R ^V Run/pick script L Lock terminal\n" - "b^P Prompt ^N Note\n"}; + "b^P Prompt ^N Note = Launcher\n"}; if (g_tmpfpath[0]) xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], @@ -3741,6 +3743,7 @@ nochange: case SEL_EXEC: // fallthrough case SEL_SHELL: // fallthrough case SEL_SCRIPT: // fallthrough + case SEL_LAUNCH: // fallthrough case SEL_RUNCMD: switch (sel) { case SEL_EXEC: @@ -3817,6 +3820,11 @@ nochange: lastname[0] = '\0'; setdirwatch(); goto begin; + case SEL_LAUNCH: + if (getutil(utils[NLAUNCH])) { + spawn(utils[NLAUNCH], NULL, NULL, path, F_NORMAL); + break; + } // fallthrough default: /* SEL_RUNCMD */ #ifndef NORL if (cfg.picker) { diff --git a/src/nnn.h b/src/nnn.h index a2a858b..dadbde6 100644 --- a/src/nnn.h +++ b/src/nnn.h @@ -88,6 +88,7 @@ enum action { SEL_EXEC, SEL_SHELL, SEL_SCRIPT, + SEL_LAUNCH, SEL_RUNCMD, SEL_RUNEDIT, SEL_RUNPAGE, @@ -224,6 +225,8 @@ static struct key bindings[] = { /* Run a custom script */ { 'R', SEL_SCRIPT }, { CONTROL('V'), SEL_SCRIPT }, + /* Launcher */ + { '=', SEL_LAUNCH }, /* Run a command */ { CONTROL('P'), SEL_RUNCMD }, /* Open in EDITOR or PAGER */ -- cgit v1.2.3-70-g09d2