5
from gettext import gettext as _
6
gettext.textdomain('my-fs-cli')
8
from subprocess import *
9
from my_fs_cli import my_fs_cliconfig
11
LEVELS = ( logging.ERROR,
19
out_file = Popen("gconftool-2 --get '/desktop/gnome/peripherals/keyboard/kbd/layouts'", shell=True, stdout=PIPE).stdout
20
out = out_file.read().strip ()
25
version = my_fs_cliconfig.__version__
26
# Support for command line options.
27
usage = _("my-fs-cli [options]")
28
parser = optparse.OptionParser(version="%%prog %s" % version, usage=usage)
29
parser.add_option('-d', '--debug', dest='debug_mode', action='store_true',
30
help=_('Print the maximum debugging info (implies -vv)'))
31
parser.add_option('-v', '--verbose', dest='logging_level', action='count',
32
help=_('set error_level output to warning, info, and then debug'))
33
# exemple of silly CLI option
34
#parser.add_option("-f", "--foo", action="store", dest="foo",
35
# help=_("foo should be assigned to bar"))
36
parser.set_defaults(logging_level=0, foo=None)
37
(options, args) = parser.parse_args()
40
if options.debug_mode:
41
options.logging_level = 3
42
logging.basicConfig(level=LEVELS[options.logging_level], format='%(asctime)s %(levelname)s %(message)s')
45
# this is the easter egg (:
46
if options.foo == 'bar':
47
logging.warning(_('easter egg found'))
50
# Run your cli application there.
51
zgy_layout = "[us,mm\tzawgyi]"
52
uni_layout = "[us,mm\tmm3]"
53
layout = get_layout ()
54
if layout == zgy_layout:
55
Popen("gconftool-2 --set --type list --list-type string '/desktop/gnome/peripherals/keyboard/kbd/layouts' '[us,mm\tmm3]'", shell=True)
56
Popen("sed -i 's/TharLon/zawgyi-one/g' ~/.fonts.conf", shell=True)
58
Popen("gconftool-2 --set --type list --list-type string '/desktop/gnome/peripherals/keyboard/kbd/layouts' '[us,mm\tzawgyi]'", shell=True)
59
Popen("sed -i 's/zawgyi-one/TharLon/g' ~/.fonts.conf", shell=True)
61
#print _("I'm launched and my args are: %s") % (" ".join(args))
62
logging.debug(_('end of prog'))
65
if __name__ == "__main__":