summaryrefslogtreecommitdiff
path: root/scripts/websearch
blob: 32d8773c29dfac1df13b32afaa4fcc269350f4dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh

browser="links-launcher"
SEARCH_ENGINE="https://librex.beparanoid.de/search.php?q="
SEARCH_HISTORY=$HOME/.local/share/search_history

SEARCH=$(cat $SEARCH_HISTORY | dmenu -p "search")

echo "$SEARCH" >> $SEARCH_HISTORY

query=$(echo $SEARCH | sed 's/ /+/g')

echo $query | grep -q '(?=^.{5,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)' && {
    links-launcher "$query"
} ||  {
    links-launcher "$SEARCH_ENGINE$query"
}