summaryrefslogtreecommitdiff
path: root/bm
blob: 8a79c2e234b92b1c561a937d1f713f01e0550d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

bmfile="$HOME/.local/share/bookmarks.txt"
url=$(tac "$bmfile" | dmenu -i -c -l 15 -p "URL:")

[ -z "$url" ] && exit
# append a url to the list if it's not present and 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 "$url" ;;
	"Copy to clipboard") printf "%s" "$url" | xclip -selection clipboard &&
		notify-send "URL copied to clipboard" ;;
	*) exit ;;
esac