Files
nix-zaneyos/scripts/web-search.nix

44 lines
1.0 KiB
Nix
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{pkgs}:
pkgs.writeShellScriptBin "web-search" ''
declare -A URLS
URLS=(
["🌎 Search"]="https://search.garandplg.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="
[" NixOS Wiki"]="https://nixos.wiki/index.php?search="
["🔎 Wikipedia"]="https://pl.wikipedia.org/w/index.php?ns0=1&search="
["👨💻 StackOverflow"]="https://stackoverflow.com/search?q="
)
# List for rofi
gen_list() {
for i in "''${!URLS[@]}"
do
echo "$i"
done
}
main() {
# Pass the list to rofi
platform=$( (gen_list) | ${pkgs.wofi}/bin/wofi -dmenu )
if [[ -n "$platform" ]]; then
query=$( (echo ) | ${pkgs.wofi}/bin/wofi -dmenu )
if [[ -n "$query" ]]; then
url=''${URLS[$platform]}$query
xdg-open "$url"
else
exit
fi
else
exit
fi
}
main
exit 0
''