| Server IP : 172.67.191.97 / Your IP : 104.23.197.209 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/LanguageSelector/ |
Upload File : |
# ImConfig.py (c) 2012-2020 Canonical
# Author: Gunnar Hjalmarsson <[email protected]>
#
# Released under the GPL
#
import os
import subprocess
import locale
class ImConfig(object):
def __init__(self):
pass
def available(self):
return os.path.exists('/usr/bin/im-config')
def getAvailableInputMethods(self):
inputMethods = sorted(subprocess.check_output(['im-config', '-l']).decode().split())
inputMethods.append('none')
return inputMethods
def getCurrentInputMethod(self):
(systemConfig, userConfig, autoConfig) = \
subprocess.check_output(['im-config', '-m']).decode().split()[:3]
if userConfig != 'missing':
return userConfig
"""
no saved user configuration
fall back to the system configuration
"""
system_conf = ''
if systemConfig == 'default':
system_conf = autoConfig
elif os.path.exists('/etc/X11/xinit/xinputrc'):
for line in open('/etc/X11/xinit/xinputrc'):
if line.startswith('run_im'):
system_conf = line.split()[1]
break
if not system_conf:
system_conf = autoConfig
return system_conf
def setInputMethod(self, im):
subprocess.call(['im-config', '-n', im])
if __name__ == '__main__':
im = ImConfig()
print('available input methods: %s' % im.getAvailableInputMethods())
print('current method: %s' % im.getCurrentInputMethod())
print("setting method 'fcitx'")
im.setInputMethod('fcitx')
print('current method: %s' % im.getCurrentInputMethod())
print('removing ~/.xinputrc')
im.setInputMethod('REMOVE')