コード例 #1
0
ファイル: main.py プロジェクト: domsblog/samurai-x
def run(app_func=None, config=None, args=None):
    configure_logging()

    options, args = parse_options(args)
    if options or args: 
        handle_options(options, args)    

    if config is None:
        config = load_user_config(options.configfile)
    load_config(config=config)

    set_process_name('samurai-x')

    xhelpers.open_display()
    xhelpers.check_for_other_wm()
    xhelpers.setup_xerror()

    init_atoms()
    xhelpers.get_numlock_mask()
    init_cursors()
    init_timer()

    if app_func is None:
        from samuraix.appl import App
        app_func = App

    log.info('creating app instance...')
    samuraix.app = app_func()
    samuraix.app.init()
    run_app()
    log.info('done')
コード例 #2
0
ファイル: setroot.py プロジェクト: domsblog/samurai-x
def run(args=None):
    from optparse import OptionParser

    from samuraix.screen import SimpleScreen
    from samuraix import xhelpers

    parser = OptionParser()

    parser.add_option("-d", "--display", dest="display_name", default=None,
                      help="display to use")
    parser.add_option("-s", "--screen", dest="screen_num", default=None, type="int",
                      help="screen number to use")

    parser.add_option("-c", "--color", dest="color", default=None,
                      help="color to use (hex style with no leading #, eg. ff0000)")
    parser.add_option("-i", "--image", dest="image", default=None,
                      help="image to use (currently only svg files are supported)")
    parser.add_option("-z", "--size", dest="image_size", nargs=2, default=None, type="int",
                      help="image size")
    parser.add_option("-p", "--pos", dest="image_position", nargs=2, default=None, type="int",
                      help="image position")
    

    #parser.add_option("-d", "--debug",
    #                  action="store_true", dest="debug", default=False,
    #                  help="print debug messages to stdout")
    #parser.add_option('-c', "--config",
    #                  dest='configfile', default=None,
    #                  help="config file to use")
    #parser.add_option('', '--dumpconfig', dest='dumpconfig', default=False,
    #                  help="dump the default config to stdout and quit")

    if args is None:
        args = sys.argv[1:]

    options, args = parser.parse_args(args=args)

    if args:
        print "this command takes no arguments - see --help"
        sys.exit(1)

    xhelpers.open_display(display_name=options.display_name)
    if options.screen_num is None:
        options.screen_num = xlib.XDefaultScreen(samuraix.display)
    screen = SimpleScreen(options.screen_num)

    try:
        set_root(screen, 
            color=options.color,
            image=options.image,
            image_size=options.image_size,
            image_position=options.image_position,
        )
    finally:
        xhelpers.close_display()
コード例 #3
0
ファイル: simplexapp.py プロジェクト: samurai-x/samurai-x
def run(app_func, nice_inc=15, name=None):
    from samuraix.procutil import set_process_name

    xhelpers.open_display()
    xhelpers.setup_xerror()

    xhelpers.get_numlock_mask()

    os.nice(nice_inc)
        
    simpleapp = app_func() #ClockApp(SimpleScreen(0), Rect(0, 0, 200, 15))

    if name is None:
        name = 'sx.%s' % simpleapp.__class__.__name__
    set_process_name(name)

    try:
        simpleapp.run()   
    finally:
        xhelpers.close_display()