3 ms·
I have a bunch of little scripts I use with my dwm installation. but the one I'm most proud of is a simple translation script where I type a phrase and it tran
by in9 4y ago
I have a bunch of little scripts I use with my dwm installation.
but the one I'm most proud of is a simple translation script where I type a phrase and it translates to my selected language and places it into my clipboard.
Since I work in three languages, this really helps with day to day communication :D
```
#!/bin/bash
choice=$(echo -e 'pt -> es\nen -> es\nes -> pt\nes -> en' | dmenu)
text_to_translate=$(echo '> what to translate?' | dmenu)
[ "$choice" = 'pt -> es' ] && res=$(trans -no-warn --brief pt:es "$text_to_translate")
[ "$choice" = 'en -> es' ] && res=$(trans -no-warn --brief en:es "$text_to_translate")
[ "$choice" = 'es -> pt' ] && res=$(trans -no-warn --brief es:pt "$text_to_translate")
[ "$choice" = 'es -> en' ] && res=$(trans -no-warn --brief es:en "$text_to_translate")
[ "$choice" = 'pt -> en' ] && res=$(trans -no-warn --brief pt:en "$text_to_translate")
notify-send "traducão" "$res"
echo "$res" | xclip -selection clipboard
```