summaryrefslogtreecommitdiff
path: root/bin/.bin/open-bookmark.sh
blob: 67e724b46b428f19b10e02ada54ca9f2b3fe4e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
set -euo pipefail

BOOKMARKS_FILE="$DOTFILES_REPO/bookmarks.txt"

if [ ! -f "$BOOKMARKS_FILE" ] || [ ! -s "$BOOKMARKS_FILE" ]; then
  notify-send "Bookmarks" "Your bookmarks file is empty or missing."
  exit 1
fi

SELECTION=$(cut -d'|' -f1 "$BOOKMARKS_FILE" | rofi -dmenu -p "Go To:")

if [ -z "$SELECTION" ]; then
  exit 0
fi

URL=$(grep "^$SELECTION|" "$BOOKMARKS_FILE" | head -n 1 | cut -d'|' -f2)

if [ -n "$URL" ]; then
  firefox "$URL" &
else
  notify-send "Error" "Could not resolve the URL for: $SELECTION"
fi