403Webshell
Server IP : 107.13.46.68  /  Your IP : 216.73.216.232
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux mariOS 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/linuxmint/mintlocale/ImConfig/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/linuxmint/mintlocale/ImConfig/ImConfig.py
# 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 getAllInputMethods(self):
        inputMethods = subprocess.check_output(['im-config', '-l', '-a']).decode().split()
        return sorted(inputMethods)

    def getCurrentInputMethod(self):
        # Output from the comamand "im-config -m" is different between Trusty (17.x) and Xenial (18.x), but the first three values are the same
        splits = subprocess.check_output(['im-config', '-m']).decode().split()
        (systemConfig, userConfig, autoConfig) = splits[0:3]

        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')

Youez - 2016 - github.com/yon3zu
LinuXploit