From 66ca7024fc2ad56ee2ddac44980c7f09bda54d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 16 May 2016 21:43:13 +0100 Subject: vis: introduce vis-menu helper script This serves as a wrapper around dmenu(1) and slmenu(1), by default the latter is preferred because it also works without an X server. The program and its default arguments can be configured by means of the $VIS_MENU and $VIS_MENU_ARGS environment variables. Eventually we might decide to inlcude a stripped down version of slmenu in the vis source tree. --- vis-menu | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 vis-menu (limited to 'vis-menu') diff --git a/vis-menu b/vis-menu new file mode 100755 index 0000000..9c432ea --- /dev/null +++ b/vis-menu @@ -0,0 +1,33 @@ +#!/bin/sh + +PATTERN="." +[ -z "$VIS_MENU" ] && VIS_MENU="slmenu" +[ -z "$VIS_MENU_ARGS" ] && VIS_MENU_ARGS="-b" + +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + echo "usage: $(basename $0) [-h] [-p prompt]" + exit 0; + ;; + -p) + VIS_MENU_ARGS="$VIS_MENU_ARGS -p $2" + shift + shift + ;; + *) + break + ;; + esac +done + +if ! type "$VIS_MENU" >/dev/null 2>&1; then + if [ ! -z "$DISPLAY" ] && type "dmenu" >/dev/null 2>&1; then + VIS_MENU="dmenu" + else + echo "Neither slmenu nor dmenu found" >&2 + exit 1 + fi +fi + +exec $VIS_MENU $VIS_MENU_ARGS -- cgit v1.2.3