#!/bin/bash

engine="https://www.google.com/search?q="

declare -A bookmarks=(    
    ["YouTube"]="https://www.youtube.com/"
    ["GitHub"]="https://github.com/TrudeEH/dotfiles"
    ["TrudeWeb"]="https://trudeeh.github.io/web/"
    ["Gemini"]="https://gemini.google.com/app"
    ["Element"]="https://app.element.io/#/home"
    ["Gmail"]="https://mail.google.com/mail/u/0/#inbox"
    ["Google Messages"]="https://messages.google.com/web/conversations"
    ["WOL"]="https://wol.jw.org/pt-PT/"
    ["Discord"]="https://discord.com/app"
)

choice=$(printf "%s\n" "${!bookmarks[@]}" | dmenu -i -p "Search:")

if [[ -n "$choice" ]]; then
    # Find the matching URL
    url=${bookmarks[$choice]}

    if [[ -n "$url" ]]; then
        xdg-open $url
    else
        xdg-open $engine$choice
    fi
fi
