summaryrefslogtreecommitdiff
path: root/sys/open-bookmark
diff options
context:
space:
mode:
Diffstat (limited to 'sys/open-bookmark')
-rwxr-xr-xsys/open-bookmark26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/open-bookmark b/sys/open-bookmark
new file mode 100755
index 0000000..12f5ae6
--- /dev/null
+++ b/sys/open-bookmark
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Open a bookmark. If the text entered is not a bookmark, search for it
+# using Duckduckgo, for now.
+
+[ -z "$BROWSER" ] && BROWSER="firefox"
+
+if [ -z "$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
+
+open="$(grep -v '^#\|^[ \r\n]*$' $file | \
+ dmenu -p 'Site to open:' -i -l 50 | \
+ cut -d'#' -f1 | \
+ sed 's/[[:space:]]*$//')"
+
+[ -z "$open" ] && exit
+if cat "$file" | grep -q "^.*$open.*$" ; then
+ notify-send "Bookmark Opened" "$open has been opened."
+ $BROWSER "$open"
+else
+ notify-send "Opened DuckDuckGo" "Seached <i>$open</i>."
+ $BROWSER "https://duckduckgo.com/?q=$(echo $open | tr ' ' '+')"
+fi