Move from slow zx to python

This commit is contained in:
2022-07-06 13:48:06 +05:30
parent bac1d356f5
commit 45e2207ecd
3 changed files with 21 additions and 19 deletions
+20
View File
@@ -0,0 +1,20 @@
#!/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])