2021-10-09 21:20:41 +00:00
|
|
|
#!/bin/sh
|
2024-04-04 17:04:16 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
# TODO make this list results in rofi/dmenu that would be coo
|
2021-10-09 21:20:41 +00:00
|
|
|
|
2023-03-10 17:06:03 +00:00
|
|
|
default_browser="links-launcher"
|
|
|
|
BROWSER=${BROWSER:-$default_browser}
|
|
|
|
SEARCH_ENGINE="https://search.davidovski.xyz/search.php?q="
|
2022-05-15 23:48:34 +00:00
|
|
|
SEARCH_HISTORY=$HOME/.local/share/search_history
|
2021-10-09 21:20:41 +00:00
|
|
|
|
|
|
|
SEARCH=$(cat $SEARCH_HISTORY | dmenu -p "search")
|
|
|
|
|
2023-11-12 23:08:36 +00:00
|
|
|
[ -z "$SEARCH" ] && exit 1
|
|
|
|
|
2022-05-15 23:48:34 +00:00
|
|
|
echo "$SEARCH" >> $SEARCH_HISTORY
|
2021-10-09 21:20:41 +00:00
|
|
|
|
2022-05-15 23:48:34 +00:00
|
|
|
query=$(echo $SEARCH | sed 's/ /+/g')
|
2021-10-09 21:20:41 +00:00
|
|
|
|
2022-05-15 23:48:34 +00:00
|
|
|
echo $query | grep -q '(?=^.{5,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)' && {
|
2023-03-10 17:06:03 +00:00
|
|
|
$BROWSER "$query"
|
2022-05-15 23:48:34 +00:00
|
|
|
} || {
|
2023-03-10 17:06:03 +00:00
|
|
|
$BROWSER "$SEARCH_ENGINE$query"
|
2022-05-15 23:48:34 +00:00
|
|
|
}
|