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

dir="$HOME/.local/share/bookmarks.txt"
bookmark=$(tac $dir | dmenu -i -c -l 15 -p "Bookmark:")

[ -z $bookmark ] && 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

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 &&
		notify-send "URL copied to clipboard" ;;
	*) exit ;;
esac