diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-05-16 21:43:13 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-05-16 22:43:13 +0200 |
| commit | 66ca7024fc2ad56ee2ddac44980c7f09bda54d80 (patch) | |
| tree | 48cd9595f6ecf779b385497efc1d57ae1be49d77 /vis-open | |
| parent | 66d7f9efac75a1920cdf152b9fcacc18adb059f9 (diff) | |
| download | vis-66ca7024fc2ad56ee2ddac44980c7f09bda54d80.tar.gz vis-66ca7024fc2ad56ee2ddac44980c7f09bda54d80.tar.xz | |
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.
Diffstat (limited to 'vis-open')
| -rwxr-xr-x | vis-open | 14 |
1 files changed, 2 insertions, 12 deletions
@@ -1,8 +1,7 @@ #!/bin/sh PATTERN="." -[ -z "$VIS_MENU" ] && VIS_MENU="slmenu" -[ -z "$VIS_MENU_ARGS" ] && VIS_MENU_ARGS="-b" +VIS_MENU_ARGS="" while [ $# -gt 0 ]; do case "$1" in @@ -22,20 +21,11 @@ while [ $# -gt 0 ]; do 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 - DIR="" [ ! -z "$PATTERN" -a "$PATTERN" != "." -a -d "$PATTERN" ] && DIR="$PATTERN" while true; do - SEL=$({ echo ..; ls -1 $PATTERN 2>/dev/null || echo $PATTERN; } | $VIS_MENU $VIS_MENU_ARGS) + SEL=$({ echo ..; ls -1 $PATTERN 2>/dev/null || echo $PATTERN; } | vis-menu $VIS_MENU_ARGS) [ -z "$SEL" ] && exit 1 [ ! -z "$DIR" ] && SEL="$DIR/$SEL" if [ -d "$SEL" ]; then |
