blob: cf37c7f0b8156ad482b6e906b6fcbf9730a0f31e (
plain) (
blame)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 | #!/bin/sh
# Adds a bookmark. 
# Either grabs xclip, or requests input of the string to bookmark. 
# If passed --ask (-a), then ignore the clipboard and prompt the user what to 
# bookmark. 
bkmk="$(xclip -o -selection primary)"
alias bmnotify-send="notify-send -i $HOME/.local/share/img/bm-icon.png"
if isflag '-a' "$@" ; then 
	bkmk="$(dmenu -p "Enter bookmark: " < /dev/null)"
fi
[ -z "$bkmk" ] && bmnotify-send "Did not bookmark." "Nothing selected to bookmark!" && exit
comment="$(dmenu -p "Add comment ($bkmk): " < /dev/null)"
[ -z "$comment" ] && exit
if [ "$ORGD_KT_PATH" = "" ]; then 
	notify-send "ORGD_KT_PATH empty." "Using $HOME/docs/wr/orgd/kt as fallback."
	file="$HOME/docs/wr/orgd/kt/bookmark"
else
	file="$ORGD_KT_PATH/bookmark"
fi
stripped="$(strip-comments "$file")"
if echo "$stripped" | grep -q "^$bkmk[/ \t]*$"; then 
	bmnotify-send "No!" "<i>$bkmk</i> already bookmarked!"
else
	echo "$bkmk # $comment" >> "$file"
	bmnotify-send "Bookmark Added!" "<i>$bkmk</i> added and tagged as <i>$comment</i>."
fi
 |