#!/bin/bash -e shopt -s extglob if [ "$1" = -p ]; then BROWSER="$BROWSER --private-window" elif [[ "$(xdotool getwindowfocus getwindowname)" != *'Mozilla Firefox' ]]; then BROWSER="$BROWSER --new-window" fi mapfile -t list < <(grep -Pv '^(#|$)' "$XDG_CONFIG_HOME/bookmarks") q="$(printf '%s\n' '' "${list[@]}" | dmenu -l 16)" if [ -z "$q" ]; then exec $BROWSER elif [[ "$q" == *://* ]]; then url="${q/*+( )/}" if [ "$1" = -p ] || [[ "$url" == http?(s)://* ]]; then exec $BROWSER "$url" fi exec xdg-open "$url" fi if [[ "$q" =~ ^[^[:space:]]+(\.[^[:space:]]+)+$ ]]; then exec $BROWSER "$q" fi exec $BROWSER "https://searx.gmoker.com/search?q=$(jq -Rr '@uri' <<< "$q")"