| Server IP : 20.75.53.88 / Your IP : 216.73.217.138 [ Web Server : Apache System : Linux VMRALP-3 4.4.0-256-generic #290~14.04.1-Ubuntu SMP Thu Jun 20 09:24:50 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29+esm15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Domains : 3 Domains MySQL : ON | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/thread-self/root/usr/lib/python3/dist-packages/LanguageSelector/ |
Upload File : |
# ImConfig.py (c) 2012-2014 Canonical
# Author: Gunnar Hjalmarsson <gunnarhj@ubuntu.com>
#
# Released under the GPL
#
import os
import subprocess
class ImConfig(object):
def __init__(self):
pass
def available(self):
return os.path.exists('/usr/bin/im-config')
def getAvailableInputMethods(self):
inputMethods = subprocess.check_output(['im-config', '-l']).decode().split()
return sorted(inputMethods)
def getCurrentInputMethod(self):
(systemConfig, userConfig, autoConfig) = \
subprocess.check_output(['im-config', '-m']).decode().split()
if userConfig != 'missing':
return userConfig
"""
no saved user configuration
let's ask the system and save the system configuration as the user ditto
"""
system_conf = ''
if os.path.exists('/usr/bin/fcitx'):
# Ubuntu Kylin special
system_conf = 'fcitx'
elif systemConfig == 'default':
# Using the autoConfig value might be incorrect if the mode in
# /etc/default/im-config is 'cjkv'. However, as from im-config 0.24-1ubuntu1
# the mode is 'auto' for all users of language-selector-gnome.
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
self.setInputMethod(system_conf)
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')