From c94b076963496341b456c0c68871c8b4d265b0c3 Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Wed, 29 Jul 2020 17:25:01 +0100 Subject: [PATCH] Work on bookmark script --- bin/.bin/dmenu/get-bookmark | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/.bin/dmenu/get-bookmark b/bin/.bin/dmenu/get-bookmark index 4069dd6b..eea8ba62 100755 --- a/bin/.bin/dmenu/get-bookmark +++ b/bin/.bin/dmenu/get-bookmark @@ -1,6 +1,13 @@ #!/usr/bin/env bash -BOOKMARKS="$HOME/.surf/bookmarks/" +BOOKMARKS="$HOME/.local/share/bookmarks/" + +isxclient=$( readlink /dev/fd/2 | grep -q 'tty' && [[ -n $DISPLAY ]] ; echo $? ) +if [[ ! -t 2 || $isxclient == "0" ]]; then + DMENU="rofi -dmenu" +else + DMENU="fzf" +fi function formatFile(){ keywords="$(grep -E '^keywords:' "$1" | sed 's/^keywords://')" @@ -10,7 +17,7 @@ export -f formatFile if [ -d "$BOOKMARKS" ]; then cd "$BOOKMARKS" - selection=$(find . -type f -exec bash -c 'formatFile "{}"' \; | dmenu -l 20 | sed 's/ : .*//') + selection=$(fd --type f --exclude README.md --exec bash -c 'formatFile "{}"' ";" . | $DMENU | sed 's/ : .*//') if [ -f "$selection" ]; then head -n 1 "$selection" fi