Skip to content

Instantly share code, notes, and snippets.

@T31337
Created November 15, 2024 23:45
Show Gist options
  • Save T31337/1dd2920baf94570feda84123f1ed56da to your computer and use it in GitHub Desktop.
Save T31337/1dd2920baf94570feda84123f1ed56da to your computer and use it in GitHub Desktop.
python script to switch to next avaiable keyboard input method
#!/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