commit 1a01ce9b465ee5793d11fac22aa5ffb75f1613cf
parent 5fd00a73cf14fcba4f56a3a08c322bf2c7d61a24
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Fri, 12 Feb 2021 21:59:18 -0800
Greatly simplify fsmenu and update scripts which use it
It's now simply a dmenu(1) wrapper around find(1).
Diffstat:
3 files changed, 20 insertions(+), 42 deletions(-)
diff --git a/modules/scripts/.local/bin/fsmenu b/modules/scripts/.local/bin/fsmenu
@@ -1,33 +1,7 @@
-#!/usr/bin/env dash
-#! fsmenu -- navigate the filesystem with dmenu
-#!
-#! The -a flag causes hidden files to be shown, the -t option passes the
-#! value to find(1)'s -type option.
+#!/bin/sh
+# Copywrite 2020, 2021 Jacob R. Edwards
+# License: GPLv3
+#
+# fsmenu -- find(1) dmenu(1) wrapper
-set -e
-
-usage() { echo "usage: `basename $0` [-a] [-t type] [directory]" ;}
-dmenu() { command dmenu -l 10 $@ ;}
-find() { command find $@ | cut -d/ -f2- ;}
-
-while [ $# -ne 0 ]
-do
- case "$1"
- in
- -a) aflag=1; shift;;
- -t) type="-type $2"; shift 2;;
- *) break;;
- esac
-done
-
-cd ${@:-"."}
-if [ ${aflag:-0} -eq 0 ]; then
- dir=`find . $type | grep -v "/\." | dmenu`
-else
- dir=`find . $type | dmenu`
-fi
-if [ $# -eq 0 ]; then
- echo $dir
-else
- echo "${@%/}/$dir"
-fi
+find $* -not -name '.*' | dmenu
diff --git a/modules/scripts/.local/bin/wpaper b/modules/scripts/.local/bin/wpaper
@@ -1,17 +1,21 @@
#!/usr/bin/env dash
-#! wpaper -- wallpaper selection
-#!
-#! If no arguments are given it simply invokes sxiv(1) on the
-#! WALLPAPER_DIR environment variable. If the -s flag is given it
-#! invokes sxiv on a directory selected with fsmenu.
+# Copywrite 2020, 2021 Jacob R. Edwards
+# License: GPLv3
+#
+# wpaper -- wallpaper selection
+#
+# By default all wallpapers under the directory specified by
+# `WALLPAPER_DIR' are opened with sxiv, however, if the `s' flag
+# is passed, fsmenu will be invoked allowing the selection of any
+# directory under `WALLPAPER_DIR'.
set -eu
-if [ $# = 0 ]; then
+if test $# -eq 0; then
sxiv -rtb $WALLPAPER_DIR
-elif [ "$1" = "-s" ]; then
- sxiv -rtb `fsmenu -t d $WALLPAPER_DIR`
+elif test "$1" = "-s"; then
+ sxiv -rtbi `fsmenu $WALLPAPER_DIR -type d`
else
- echo "`basename $0`: $1: Invalid argument" 1>&2
+ printf 'usage: %s [-s]\n' `basename $0` 1>&2
exit 1
fi
diff --git a/modules/sxiv/.config/sxiv/exec/key-handler b/modules/sxiv/.config/sxiv/exec/key-handler
@@ -19,7 +19,7 @@ switch ($1) {
case 'C-w'
cw $buf($#buf);
case 'C-m'
- mv $buf `{ fsmenu -t -d }
+ mv $buf `{ fsmenu . -type d }
case 'C-x'
yes && rm $buf
case *