From 1bd89daea4e7e29ebadf8926f35db39d636402a9 Mon Sep 17 00:00:00 2001 From: tsxv478 Date: Fri, 21 Apr 2023 01:00:44 +0300 Subject: fix bm --- bm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bm b/bm index baffdfe..8a79c2e 100755 --- a/bm +++ b/bm @@ -1,17 +1,17 @@ #!/bin/sh -dir="$HOME/.local/share/bookmarks.txt" -bookmark=$(tac $dir | dmenu -i -c -l 15 -p "Bookmark:") +bmfile="$HOME/.local/share/bookmarks.txt" +url=$(tac "$bmfile" | dmenu -i -c -l 15 -p "URL:") -[ -z $bookmark ] && exit +[ -z "$url" ] && exit # append a url to the list if it's not present and exit -[ -z $(grep -F $bookmark $dir) ] && printf "%s\n" "$bookmark" >> $dir && exit +grep -Fq "$url" "$bmfile" || { printf "%s\n" "$url" >> "$bmfile" ; exit ; } action=$(printf "Open in browser\nCopy to clipboard" | dmenu -i -c -l 2 -p "Action:") -case $action in - "Open in browser") $BROWSER $bookmark ;; - "Copy to clipboard") printf "%s" "$bookmark" | xclip -selection clipboard && +case "$action" in + "Open in browser") $BROWSER "$url" ;; + "Copy to clipboard") printf "%s" "$url" | xclip -selection clipboard && notify-send "URL copied to clipboard" ;; *) exit ;; esac -- cgit v1.2.3