dots

my dotfiles
git clone https://git.awy.one/dots
Log | Files | Refs | Submodules | README | LICENSE

commit 4cee45067d677f76f75e29da175eb51eae5e12fd
parent 16a6726c91f0e6cc1787b0a1e8442d6f2842f4f5
Author: awy <awy@awy.one>
Date:   Sat, 27 Dec 2025 22:34:08 +0300

translate script

Diffstat:
A.local/bin/tslate | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/.local/bin/tslate b/.local/bin/tslate @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +tquery=${1:-$(xclip -o -selection primary 2>/dev/null || wl-paste 2>/dev/null)} +encoded_query=$(echo "$tquery" | jq -sRr @uri) + +query=$(curl -s --connect-timeout 5 --max-time 10 -X 'GET' \ + "https://mozhi.canine.tools/api/translate?engine=google&from=auto&to=ru&text=$encoded_query" \ + -H 'accept: application/json') + +# Check for connection error (curl exit status stored in $?) +[ $? -ne 0 ] && notify-send -h string:bgcolor:#bf616a -t 3000 "Connection error." && exit 1 + +translated_text=$(echo "$query" | jq -r '.["translated-text"]') +lang=$(echo "$query" | jq -r '.["detected"]') + +notify-send -t 60000 "$translated_text" "$tquery ($lang)"