Created
December 3, 2015 06:22
-
-
Save fzerorubigd/3cf3f0d915c8ca0f68b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # A simple convertor for change the text from selection and replace all persian charachter with | |
| # English charachter in clipboard. | |
| # Just assign it to a key binding, with anything you like (i3 for example). | |
| # I wrote this for http://linuxvaman.ir/ | |
| # Publishe under WTFPL | |
| # fzerorubigd <[email protected]> 2 Dec 2015 | |
| change_string() { | |
| persian=( ض ص ث ق ف غ ع ه خ ح ج چ ش س ی ب ل ا ت ن م ک گ ظ ط ز ر ذ د پ و ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ۰ ! ٬ ٫ ﷼ ٪ × ، ؛ ) | |
| english=( q w e r t y u i o p \[ \] a s d f g h j k l \; \' z x c v b n m , 1 2 3 4 5 6 7 8 9 0 ! @ \# \$ % \^ \& \' ) | |
| len=$(echo ${#english[*]}) | |
| arg=$@ | |
| for ((i=1 ; i < $len ; i++)) do | |
| arg=${arg//${persian[$i]}/${english[$i]}} | |
| done | |
| echo "$arg" | |
| } | |
| change_string $(xsel)|xclip -selection c | |
| #sleep here is for the key binding. it is so fast, and normally, faster than you. | |
| # so, when this line is run, you are stil pressing the key binding. just | |
| # give it a rest until you move your lazy finger :) | |
| sleep 1 | |
| xdotool type "$(change_string $(xsel))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment