use conf terminal first, add mimeopen

This commit is contained in:
yosh 2023-08-10 21:44:31 -05:00
parent 4587a6999b
commit f317ec831e
2 changed files with 25 additions and 3 deletions

21
mimeopen Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
set -euf
# wrapper to use mimix instead of the perl mimeopen thing
# was made for wyeb but I then realized you can change it
# so... don't think this is all that useful anymore
# strip args
for w; do
case $w in
(--) shift; break ;;
(-*) shift ;;
(*) break ;;
esac
done
if [ -n "${1:-}" ]; then
xdg-open "$1"
else
echo "no argument provided!" >&2
fi

View File

@ -5,7 +5,7 @@ BN="${0##*/}"
### HELPER FUNCTIONS
exists() { type "$@" >/dev/null 2>&1; }
exists() { type "$1" >/dev/null 2>&1; }
errecho() { echo "$*" >&2 ; }
die() {
errecho "$*"
@ -106,7 +106,8 @@ done
[ -z "${CONFIG:-}" ] && usage && die 'Error: no config file found!'
# special variables (TERMINAL, MENU)
TERMINAL="${TERMINAL:-$(config_search TERMINAL)}"
conf_term="$(config_search TERMINAL)"
[ -n "$conf_term" ] && TERMINAL="$conf_term"
! exists "$TERMINAL" && die 'Error: $TERMINAL is not executable! Try setting it in the config.'
export TERMINAL
MENU="$(config_search MENU)" || MENU=dmenu
@ -164,7 +165,7 @@ done
# ask
if exists "$MENU"; then
cmd="$(IFS=':'; set -- $PATH; find "$@" \( -type f -o -type l \) | awk -F '/' '{print $NF}' | sort | uniq | eval "$MENU"' -p "How open ${ARG##*/}?"')"
cmd="$(IFS=':'; set -- $PATH; find "$@" \( -type f -o -type l \) | awk -F '/' '{print $NF}' | sort | uniq | eval "$MENU"' -p "How open ${ARG}?"')"
if [ -n "$cmd" ]; then
fork_run "$cmd $ARG"
else die 'Blank command from menu, exiting...'