diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-26 08:01:16 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-26 08:01:16 +0200 |
| commit | 8685afde21bf8e94071dbf0b0171b4a2e91492cf (patch) | |
| tree | 1c01c0ab871f8cb1cc126039e8e43f86fca69625 /examples/tools/search.sh | |
| parent | de179d288a1c67bc77756141b16e95c364e941a1 (diff) | |
| download | desktop-assistant-8685afde21bf8e94071dbf0b0171b4a2e91492cf.tar.gz desktop-assistant-8685afde21bf8e94071dbf0b0171b4a2e91492cf.zip | |
Add example config and the now and search tools
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'examples/tools/search.sh')
| -rwxr-xr-x | examples/tools/search.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/tools/search.sh b/examples/tools/search.sh new file mode 100755 index 0000000..a7d05dc --- /dev/null +++ b/examples/tools/search.sh @@ -0,0 +1,29 @@ +#!/bin/bash +# desktop-assistant tool: web search through a SearXNG instance. +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# 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; } |
