#!/bin/sh #inspired by 'firemenu' by on github # BRWMENU: set -e DMENU_OPTS="-i -fn DepartureMono:size=10 -nb #151515 -nf #bbbbbb -sb #884757 -sf #eeeeee" BROWSER="mullvad-browser-bin" SWALLOW="" NOTIFIER="notify-send" for cmd in dmenu "$BROWSER"; do if ! command -v "$cmd" >/dev/null 2>&1; then echo "Error: Required command '$cmd' not found" >&2 exit 1 fi done CHOICES="Startpage\nURL\nIncognito URL\nYouTube\nGithub\nCodeberg\ncoasteen.github.io\nIPLeak\nSafebooru\nWikipedia" PROMPT="Where to?" open_url() { if [ -z "$1" ]; then $NOTIFIER "Error" "No URL specified" 2>/dev/null || echo "Error: No URL specified" >&2 exit 1 fi if ! $SWALLOW $BROWSER "$1" >/dev/null 2>&1; then $NOTIFIER "Error" "Failed to open browser with URL: $1" 2>/dev/null || \ echo "Error: Failed to open browser with URL: $1" >&2 exit 1 fi } get_input() { prompt="$1" prefix="$2" input=$(printf '' | dmenu $DMENU_OPTS -p "$prompt" 2>/dev/null) if [ -z "$input" ]; then $NOTIFIER "Error" "No input provided" 2>/dev/null || echo "Error: No input provided" >&2 exit 1 fi input=$(printf "%s" "$input" | sed 's/ /%20/g') echo "${prefix}${input}" } CHOICE=$(printf "$CHOICES" | dmenu $DMENU_OPTS -p "$PROMPT" 2>/dev/null) case "$CHOICE" in Github) url=$(get_input "Username & repo:" "https://github.com/") open_url "$url" ;; Codeberg) url=$(get_input "Username & repo:" "https://codeberg.org/") open_url "$url" ;; IPLeak) open_url "https://ipleak.net" ;; Startpage) query=$(get_input "Search Startpage:" "") open_url "https://www.startpage.com/do/search?q=" ;; Wikipedia) query=$(get_input "Search Wikipedia:" "") open_url "https://en.wikipedia.org/wiki/Special:Search?search=$query" ;; URL) url=$(get_input "Enter URL:" "") case "$url" in http://*|https://*) ;; *) url="https://$url" ;; esac open_url "$url" ;; Incognito\ URL) url=$(get_input "Enter incognito URL:" "") case "$url" in http://*|https://*) ;; *) url="https://$url" ;; esac if ! $SWALLOW brave-bin --incognito "$url" >/dev/null 2>&1; then $NOTIFIER "Error" "Failed to open incognito window" 2>/dev/null || \ echo "Error: Failed to open incognito window" >&2 exit 1 fi ;; YouTube) query=$(get_input "Search YouTube:" "") open_url "https://youtube.com/results?search_query=$query" ;; Safebooru) query=$(get_input "Search Safebooru:" "") open_url "https://safebooru.org/index.php?page=post&s=list&tags=$query" ;; coasteen.github.io) open_url "https://coasteen.github.io/www/" ;; *) $NOTIFIER "Error" "Invalid selection: $CHOICE" 2>/dev/null || \ echo "Error: Invalid selection: $CHOICE" >&2 exit 1 ;; esac