Created
November 15, 2024 23:45
-
-
Save T31337/1dd2920baf94570feda84123f1ed56da to your computer and use it in GitHub Desktop.
python script to switch to next avaiable keyboard input method
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
#!/usr/bin/env python | |
import subprocess | |
import json | |
def ex(cmd): | |
return subprocess.getoutput(cmd) | |
engineList = ex('ibus read-config | grep preload-engines | sed "s/preload-engines://g; s/\'/\\"/g"') | |
engineList = json.loads(engineList) | |
currentEngine = ex('ibus engine') | |
currentEngineIdx = engineList.index(currentEngine); | |
nextEngineIdx = currentEngineIdx+1; | |
if nextEngineIdx == len(engineList): | |
nextEngineIdx=0 | |
ex('ibus engine %s' % engineList[nextEngineIdx]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment