summaryrefslogtreecommitdiff
path: root/scripts/gui/br
blob: 7530104eb7cd788eadab7e5a4bff239988bbd5d7 (plain)
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

. "lib_common.sh"

help() {
cat << EOF
${progname}: Open links from bookmarks through dmenu
options:
[link]           Open link
 -h              Print this message and exit

NOTE: bookmarks file is located at ~/.config/sites/bookmarks.txt
EOF
exit 0
}

[ -z "${BROWSER}" ] && BROWSER="firefox"

if [ "${#}" -eq 0 ]; then
	bookmark_path="${XDG_CONFIG_HOME:-$HOME/.config}/sites/bookmarks.txt"
	[ -e "${bookmark_path}" ] || err "Couldn't find bookmarks file"

	. "lib_handle.sh"

	link=$(< "${bookmark_path}" menu_handle center)

	[ -z "${link}" ] || "${BROWSER}" "${link}"
	exit $?
fi

[ "${#}" -ne 1 ] && invalid_use
[ "${1}" = "-h" ] && help

"${BROWSER}" "${1}"