Last active
November 16, 2019 19:14
-
-
Save guy-kdm/f7aee5fa8624477a9c2175ce6a9ef2c8 to your computer and use it in GitHub Desktop.
Speak two languages? Use two keyboard layouts and often start typing using the wrong one? If you're using Gnome keybind this script (super+space on my macine) and invoke to retype using the correct layout. Only Hebrew is supported but it's very easy to adapt to other layouts, just change ISL variable to your layout.
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 | |
USL="tcdsvuzjyhfknbxgpmera,.;oil[]wq\/'" | |
ISL="אבגדהוזחטיכלמנסעפצקרשתץףםןך]['\/.," | |
CURRENT=`nohup gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().currentSource.index"` | |
xdotool sleep 0.125 getwindowfocus key Shift+Home | |
if [ "$CURRENT" == "(true, '1')" ]; then | |
RES=`xclip -o -selection primary | sed -e "y/$ISL/$USL/"` | |
nohup gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[0].activate()" | |
else | |
RES=`xclip -o -selection primary | sed -e "y/$USL/$ISL/"` | |
nohup gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager().inputSources[1].activate()" | |
fi | |
xdotool type --delay 0 "$RES" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment