Skip to content

Instantly share code, notes, and snippets.

@premek
Created October 30, 2018 21:26
Show Gist options
  • Save premek/c207198795aac3e7b6da269dbd92cd5f to your computer and use it in GitHub Desktop.
Save premek/c207198795aac3e7b6da269dbd92cd5f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# translates any selection and displays the result in a notification.
# Install:
# - sudo apt install libnotify-bin xsel jq
# - you can copy this file to ~/bin, /usr/local/bin or somewhere and make it executable
# - configure a hotkey to execute it. You can use xbindkeys or your DE settings
in=$(xsel -o | sed "s/[\"'<>]//g")
notify-send --icon=info "$in" "$(wget -U "Mozilla/5.0" -qO - "http://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q=$in" |jq -r '.[0][0:]|.[]|.[1]')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment