#!/bin/bash # desktop-assistant tool: web search through a SearXNG instance. # Copyright (C) 2026 Danilo M. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # search.sh QUERY: prints the top 5 results as "title: snippet". # Needs SEARXNG_URL (config.toml [env]) with the JSON format enabled. set -uo pipefail [ -n "${SEARXNG_URL:-}" ] || { echo "SEARXNG_URL is not set" >&2; exit 1; } [ -n "${1:-}" ] || { echo "empty query" >&2; exit 1; } curl -fsS --max-time 8 --get "$SEARXNG_URL/search" \ --data-urlencode "q=$1" --data-urlencode "format=json" \ | jq -r '.results[:5][] | "\(.title): \(.content // "")"' \ || { echo "search failed" >&2; exit 1; }