From ccbd3e249b76e5993b14fca415d373b27aaa26cf Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 02:38:35 +0500 Subject: [PATCH] Properly check if executable is in PATH --- rofi-checklist.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rofi-checklist.sh b/rofi-checklist.sh index 83884d3..f57898b 100755 --- a/rofi-checklist.sh +++ b/rofi-checklist.sh @@ -41,21 +41,24 @@ done [[ $completed_tasks = "n" ]] && clear_completed="" # Check for rofi/dmenu +exe_exists() { + command -v "$1" >/dev/null +} if [[ -n $1 ]]; then menu=$1 -elif [[ -f /usr/bin/rofi ]]; then +elif exe_exists rofi; then menu=rofi -elif [[ -f /usr/bin/dmenu ]]; then +elif exe_exists dmenu; then menu=dmenu else echo "Please install either rofi or dmenu"; exit 1 fi case $menu in rofi) - [[ -f /usr/bin/rofi ]] || { echo "rofi isn't installed"; exit 1; } + exe_exists rofi || { echo "rofi isn't installed"; exit 1; } command="rofi -dmenu"; options="-selected-row 2" ;; dmenu) - [[ -f /usr/bin/dmenu ]] || { echo "dmenu isn't installed"; exit 1; } + exe_exists dmenu || { echo "dmenu isn't installed"; exit 1; } command=dmenu ;; *) echo "Please install either rofi or dmenu"; exit 1 ;;