Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / lib / python3 / dist-packages / LanguageSelector / | server ip : 104.21.89.46 your ip : 172.70.80.135 H O M E |
Filename | /usr/lib/python3/dist-packages/LanguageSelector/ImConfig.py |
Size | 2.06 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:54 |
Last modified | 09-Apr-2014 21:59 |
Last accessed | 06-Jul-2025 10:32 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
# ImConfig.py (c) 2012-2014 Canonical
# Author: Gunnar Hjalmarsson <[email protected]>
#
# 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')
# Author: Gunnar Hjalmarsson <[email protected]>
#
# 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')