2024-05-15 00:53:36 +02:00
|
|
|
|
{ pkgs }:
|
|
|
|
|
|
|
|
|
|
pkgs.writeShellScriptBin "web-search" ''
|
2024-05-15 01:36:40 +02:00
|
|
|
|
declare -A URLS
|
|
|
|
|
|
|
|
|
|
URLS=(
|
|
|
|
|
["🌎 Search"]="https://search.brave.com/search?q="
|
|
|
|
|
["❄️ Unstable Packages"]="https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query="
|
|
|
|
|
["🎞️ YouTube"]="https://www.youtube.com/results?search_query="
|
|
|
|
|
["🦥 Arch Wiki"]="https://wiki.archlinux.org/title/"
|
|
|
|
|
["🐃 Gentoo Wiki"]="https://wiki.gentoo.org/index.php?title="
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# List for rofi
|
|
|
|
|
gen_list() {
|
|
|
|
|
for i in "''${!URLS[@]}"
|
|
|
|
|
do
|
|
|
|
|
echo "$i"
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
main() {
|
|
|
|
|
# Pass the list to rofi
|
2024-05-17 10:32:17 +02:00
|
|
|
|
platform=$( (gen_list) | ${pkgs.wofi}/bin/wofi -dmenu )
|
2024-05-15 01:36:40 +02:00
|
|
|
|
|
|
|
|
|
if [[ -n "$platform" ]]; then
|
2024-05-17 10:32:17 +02:00
|
|
|
|
query=$( (echo ) | ${pkgs.wofi}/bin/wofi -dmenu )
|
2024-05-15 01:36:40 +02:00
|
|
|
|
|
|
|
|
|
if [[ -n "$query" ]]; then
|
|
|
|
|
url=''${URLS[$platform]}$query
|
|
|
|
|
xdg-open "$url"
|
|
|
|
|
else
|
|
|
|
|
exit
|
|
|
|
|
fi
|
2024-05-15 00:53:36 +02:00
|
|
|
|
else
|
2024-05-15 01:36:40 +02:00
|
|
|
|
exit
|
2024-05-15 00:53:36 +02:00
|
|
|
|
fi
|
2024-05-15 01:36:40 +02:00
|
|
|
|
}
|
2024-05-15 00:53:36 +02:00
|
|
|
|
|
2024-05-15 01:36:40 +02:00
|
|
|
|
main
|
2024-05-15 00:53:36 +02:00
|
|
|
|
|
2024-05-15 01:36:40 +02:00
|
|
|
|
exit 0
|
2024-05-15 00:53:36 +02:00
|
|
|
|
''
|