From ccbd3e249b76e5993b14fca415d373b27aaa26cf Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 02:38:35 +0500 Subject: [PATCH 1/5] 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 ;; From 1be1094f4161cd97e4148fbd4c5ebed8c796ff79 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 03:01:42 +0500 Subject: [PATCH 2/5] Add -l 10 option to dmenu --- rofi-checklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rofi-checklist.sh b/rofi-checklist.sh index f57898b..a3eb51d 100755 --- a/rofi-checklist.sh +++ b/rofi-checklist.sh @@ -59,7 +59,7 @@ case $menu in command="rofi -dmenu"; options="-selected-row 2" ;; dmenu) exe_exists dmenu || { echo "dmenu isn't installed"; exit 1; } - command=dmenu ;; + command=dmenu; options="-l 10" ;; *) echo "Please install either rofi or dmenu"; exit 1 ;; esac From 7b39af75f27155c13aa007c74b890492f648e0e8 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 03:07:02 +0500 Subject: [PATCH 3/5] Remove unnecessary '\n' --- rofi-checklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rofi-checklist.sh b/rofi-checklist.sh index a3eb51d..dcc4161 100755 --- a/rofi-checklist.sh +++ b/rofi-checklist.sh @@ -65,7 +65,7 @@ case $menu in esac # Run rofi/dmenu, replace display checkmarks with raw syntax -selection=`printf "%s%s%s\n" "$clear" "$clear_completed" "$list" | eval "$command -i $options -p \" Task:\""` +selection=`printf "%s%s%s" "$clear" "$clear_completed" "$list" | eval "$command -i $options -p \" Task:\""` selection=${selection//"$EMPTY"/"$EMPTY_RAW"} selection=${selection//"$FILLED"/"$FILLED_RAW"} From 650ca05f6ebe1606902d25ebfb713499fde946de Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 03:08:08 +0500 Subject: [PATCH 4/5] Better shebang: /usr/bin/env bash --- rofi-checklist.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rofi-checklist.sh b/rofi-checklist.sh index dcc4161..5b02b63 100755 --- a/rofi-checklist.sh +++ b/rofi-checklist.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Setup constants NL=$'\n' From 51492c80e2e7704271c230461c18076183d4b228 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sat, 14 May 2022 03:18:37 +0500 Subject: [PATCH 5/5] /usr/local/bin is a preferred location --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73c348a..5968752 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ Ensure rofi is installed, then clone this repository, ```SH git clone https://github.com/ElnuDev/rofi-checklist.git ``` -and copy [rofi-checklist.sh](rofi-checklist.sh) to `/usr/bin/rofi-checklist`. +and copy [rofi-checklist.sh](rofi-checklist.sh) to `/usr/local/bin/rofi-checklist`. -Alternatively you can curl/wget the file straight to `/usr/bin/rofi-checklist` and add the executable flag manually. +Alternatively you can curl/wget the file straight to `/usr/local/bin/rofi-checklist` and add the executable flag manually. ## Usage