def run(): """PyWO run function.""" # parse commandline (options, args) = commandline.parse_args() # setup loggers setup_loggers(options.debug, options.logpath) # load config settings config = Config(options.config) if options.start_daemon: log.info('Starting PyWO daemon...') daemon.setup(config) daemon.start() elif options.list_windows: list_windows() elif options.help_more: commandline.print_help_more(config) elif options.help_actions: print '\n'.join(commandline.get_action_descriptions()) elif options.help_sections: print '\n'.join(commandline.get_section_descriptions(config)) elif args or options.action: try: actions.perform(options, args, config) except actions.ActionException, exc: commandline.print_error(exc)
def run(): """PyWO run function.""" # parse commandline (options, args) = commandline.parse_args() # setup loggers setup_loggers(options.debug, options.logpath) # load config settings config = Config(options.config) if options.start_daemon: log.info('Starting PyWO daemon...') daemon.setup(config) daemon.start() elif options.list_windows: WM = WindowManager() windows = WM.windows( filters.AND( filters.ExcludeType(Type.DESKTOP, Type.SPLASH), filters.ExcludeState(State.SKIP_PAGER, State.SKIP_TASKBAR))) for window in windows: state = window.state win_desktop = window.desktop desktop = [win_desktop, -1][State.STICKY in state or \ win_desktop == Window.ALL_DESKTOPS] if State.HIDDEN in state and \ not State.SHADED in state: state_flags = 'i' elif State.FULLSCREEN in state: state_flags = 'F' elif State.MAXIMIZED_HORZ in state and \ State.MAXIMIZED_VERT in state: state_flags = 'M' elif State.MAXIMIZED_VERT in state: state_flags = 'V' elif State.MAXIMIZED_HORZ in state: state_flags = 'H' else: state_flags = ' ' # TODO: State.ABOVE, State.BELOW state_flags += [' ', 's'][State.SHADED in state] # and \ #not State.HIDDEN in state] print '%s %s %s %s' % (window.id, desktop, state_flags, window.name) elif options.help_more: commandline.print_help_more(config) elif args or options.action: try: actions.perform(options, args, config) except actions.ActionException, exc: commandline.print_error(exc)
def run(): """PyWO run function.""" # parse commandline (options, args) = commandline.parse_args() # setup loggers setup_loggers(options.debug, options.logpath) # load config settings config = Config(options.config) if options.start_daemon: log.info('Starting PyWO daemon...') daemon.setup(config) daemon.start() elif options.list_windows: WM = WindowManager() windows = WM.windows(filters.AND( filters.ExcludeType(Type.DESKTOP, Type.SPLASH), filters.ExcludeState(State.SKIP_PAGER, State.SKIP_TASKBAR))) for window in windows: state = window.state win_desktop = window.desktop desktop = [win_desktop, -1][State.STICKY in state or \ win_desktop == Window.ALL_DESKTOPS] if State.HIDDEN in state and \ not State.SHADED in state: state_flags = 'i' elif State.FULLSCREEN in state: state_flags = 'F' elif State.MAXIMIZED_HORZ in state and \ State.MAXIMIZED_VERT in state: state_flags = 'M' elif State.MAXIMIZED_VERT in state: state_flags = 'V' elif State.MAXIMIZED_HORZ in state: state_flags = 'H' else: state_flags = ' ' # TODO: State.ABOVE, State.BELOW state_flags += [' ', 's'][State.SHADED in state]# and \ #not State.HIDDEN in state] print '%s %s %s %s' % (window.id, desktop, state_flags, window.name) elif options.help_more: commandline.print_help_more(config) elif args or options.action: try: actions.perform(options, args, config) except actions.ActionException, exc: commandline.print_error(exc)
class DBusService(dbus.service.Object): CONFIG = None @dbus.service.method("net.kosciak.PyWO", in_signature='si', out_signature='s') def PerformAction(self, command, win_id): log.debug('DBUS: command="%s", win_id=%s' % (command, win_id)) try: (options, args) = parser.parse_args(command.encode('utf-8')) log.info(options) except parser.ParserException, exc: log.exception('ParserException: %s' % exc) return 'ERROR: %s' % exc try: actions.perform(options, args, self.CONFIG, win_id) return '' except actions.ActionException, exc: log.exception('ActionException: %s' % exc) return 'ERROR: %s' % exc