From 0bf64479470a2c871c83d7e6523cdd7e506485b7 Mon Sep 17 00:00:00 2001 From: ahwx Date: Thu, 26 Feb 2026 00:28:04 +0100 Subject: [PATCH] chore: makes notes script compatible with devices that do not have bemenu (darwin) --- modules/home/scripts/scripts/notes.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/home/scripts/scripts/notes.sh b/modules/home/scripts/scripts/notes.sh index 1644df1..004fbbf 100644 --- a/modules/home/scripts/scripts/notes.sh +++ b/modules/home/scripts/scripts/notes.sh @@ -7,15 +7,30 @@ NOTEDIR="$HOME/Notes" -CHOSEN=$(find "$HOME/Notes" -follow | grep -E '.md$' | bemenu -l 10 --ignorecase) +if [ $(command -v bemenu) ]; then + MENUCMD="bemenu -l 10 --ignorecase" +elif [ $(command -v fzf) ]; then + MENUCMD="fzf" +else + exit 1 +fi + +if [ $(command -v notify-send) ]; then + NOTICMD="notify-send \"Pulling from Git...\"" +elif [ $(command -v fzf) ]; then + NOTICMD="osascript -e \'display notification \"Pulling from Git...\"\'" +else + exit 1 +fi + +CHOSEN=$(find "$HOME/Notes" -follow | grep -E '.md$' | $MENUCMD) cd "$NOTEDIR" || mkdir -p "$NOTEDIR" && cd "$NOTEDIR" || echo 'Error with moving into directory, is "$NOTEDIR" set?' # Change dir to notes dir, if it doesn't exist, create it and try again. Otherwise it should just die, I guess? echo "Check if connected to internet and pull changes from Git" -ping -c1 github.com >/dev/null && notify-send "$(git pull)" # Pull most recent changes, be sure to not create conficts... +ping -c1 github.com >/dev/null && $NOTICMD # Pull most recent changes, be sure to not create conficts... if [ "$CHOSEN" ]; then kitty -e nvim "$CHOSEN" # Finally open chosen note - git add "$CHOSEN" && git commit -m "chore: updates (auto)" && git push && notify-send "Changes pushed" else exit 1