forked from pool/fcitx5
4b3105e741
- can start via systemd user service on wayland - fix typo and requirements OBS-URL: https://build.opensuse.org/request/show/946559 OBS-URL: https://build.opensuse.org/package/show/M17N/fcitx5?expand=0&rev=19
38 lines
769 B
Python
38 lines
769 B
Python
#!/usr/bin/env python3
|
|
|
|
from os import listdir
|
|
from os.path import isdir, isfile, join
|
|
|
|
def get_input_methods():
|
|
mypath = "/etc/X11/xim.d/en"
|
|
files = []
|
|
if isdir(mypath):
|
|
files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
|
|
if not files:
|
|
mypath = "/usr/etc/X11/xim.d/en"
|
|
if isdir(mypath):
|
|
files = [f for f in listdir(mypath) if isfile(join(mypath, f))]
|
|
return files
|
|
|
|
def get_current_input_method():
|
|
i = 0
|
|
j = 0
|
|
s = ""
|
|
m = get_input_methods()
|
|
if not m:
|
|
return s
|
|
for im in m:
|
|
arr = im.split('-')
|
|
if j == 0:
|
|
i = arr[0]
|
|
s = arr[1]
|
|
j+=1
|
|
continue
|
|
if int(arr[0]) < i:
|
|
i = arr[0]
|
|
s = arr[1]
|
|
j+=1
|
|
return s
|
|
|
|
print("INPUT_METHOD={}".format(get_current_input_method()))
|