Hi community!
With the following script you can translate small sentences and words using a keyboard shortcut!
- start via shortcut
- or via Terminal
- enter text
- notification with translation
- clipboard with translation
The following packages are needed
- Menu: rofi, rofi-dmenu
- Notifications: libnotify
- Translation: translate-shell
- Clipboard: xclip
Install dependencies
sudo pacman -S rofi rofi-dmenu libnotify translate-shell xclip
Install script
#!/bin/sh
# translates text from rofi prompt to clipboard and creates a notfication
notify-send -t 5000 "Translation" "$(trans -b "$(rofi -dmenu -p translate &)" | tr -d '\n' | xclip -sel clip -f)"
If you see something in the script that can be improved, feel free to write a comment :)