예제 #1
0
    def __init__(self,
                 name='upower',
                 colors=wmii.cache['normcolors'],
                 warn_colors=wmii.cache['urgentcolors']):

        bus = get_system_bus(_BUS, _PATH)
        battery_path = ac_path = None
        for device in bus.get_interface().EnumerateDevices():
            if 'battery' in device:
                battery_path = device
            elif 'line_power' in device:
                ac_path = device
        if not battery_path or not ac_path:
            return

        self.button = Button('right', name, colors)
        self.colors = colors
        self.warn_colors = warn_colors
        self.warned = False

        def click_event(button):
            return Match('RightBarClick', button, self.button.real_name)

        events.bind({click_event(_): lambda *a: self.toggle_dialog()})

        self.battery = bus.get_prop_interface(_DEV_IFACE, battery_path)
        self.ac = bus.get_prop_interface(_DEV_IFACE, ac_path)
        self.refresh = bus.get_interface(_DEV_IFACE, battery_path).Refresh
        bus.add_callback(self.update, 'Changed', _DEV_IFACE, battery_path)
        self.update()
예제 #2
0
    def __init__(self,
                 name='volume',
                 colors=None,
                 channel='Master',
                 device=None):
        self.channel = channel
        self.device = device
        self.button = Button('right', name, colors)

        keys.bind('main', (
            "Volume control",
            ('XF86AudioMute', "Toggle mute volume", lambda k: self.toggle()),
            ('XF86AudioRaiseVolume', "Raise the volume", lambda k: self.up()),
            ('XF86AudioLowerVolume', "Lower the volume",
             lambda k: self.down()),
        ))

        def click_event(button):
            return Match('RightBarClick', button, self.button.real_name)

        events.bind({
            click_event('1'): lambda *a: self.toggle(),
            click_event('3'): lambda *a: self.set_using_menu(),
            click_event('4'): lambda *a: self.up(),
            click_event('5'): lambda *a: self.down()
        })

        self.refresh()
예제 #3
0
def register():
	global actionMatchKey
	from pygmi import events, Match
	if actionMatchKey is not None:
		unload()
	actionMatchKey = Match('Action')
	events.bind({
		actionMatchKey: dispatch_action,
		})
예제 #4
0
    def __init__(self, name='memory', colors=None, interval=6.0):
        monitor.defmonitor(self._monitor_action,
                           name=name,
                           colors=colors,
                           interval=interval)

        def click_event(button):
            real_name = monitor.monitors[name].button.real_name
            return Match('RightBarClick', button, real_name)

        events.bind({click_event(_): lambda *a: self._toggle_dialog(name)})
예제 #5
0
def keepLockEmpty():
	global keepLockEmptyKey
	from pygmi import events, Match, Client
	def retag(event, tag, client):
		print 'retagging', client
		if Client(client).tags != '+/./':
			Client(client).tags = '+'.join(map(str, range(10)))
	if keepLockEmptyKey is not None:
		unload()
	keepLockEmptyKey = Match('ViewAttach', '!lock')
	events.bind({
		keepLockEmptyKey: retag,
		})
예제 #6
0
 def __init__(self,
              name='mail',
              colors=None,
              warn_colors=None,
              warn_level=5):
     if not colors: colors = wmii.cache['normcolors']
     if not warn_colors: warn_colors = wmii.cache['urgentcolors']
     self.colors = colors
     self.warn_colors = warn_colors
     self.warn_level = warn_level
     self.button = Button('right', name, colors)
     events.bind({'Mail': lambda args: self._mail(args)})
     self._mail('init 0')
예제 #7
0
    def __init__(self, name='network', colors=None):
        self.button = Button('right', name, colors)
        self.iface = None
        self.conn = None

        bus = get_system_bus('org.wicd.daemon', '/org/wicd/daemon')
        bus.add_callback(self._status_changed, 'StatusChanged')
        bus.get_interface().GetConnectionStatus(
            reply_handler=lambda args: self._status_changed(*args),
            error_handler=lambda args: self._error_handler(*args))

        def click_event(button):
            return Match('RightBarClick', button, self.button.real_name)

        events.bind({click_event(_): lambda *a: self.toggle_dialog()})
예제 #8
0
    def __init__(self, name='network', colors=None):
        self.button = Button('right', name, colors)
        self.ap_signal = None

        self.bus = get_system_bus(_NM_BUS, _NM_PATH)
        self.bus.add_callback(self._prop_changed, 'PropertiesChanged')
        conns = self.bus.get_prop_interface().ActiveConnections
        if conns:
            self._handle_connection(conns[0])
        else:
            self.button.label = 'N: -'

        def click_event(button):
            return Match('RightBarClick', button, self.button.real_name)

        events.bind({click_event(_): lambda *a: self.toggle_dialog()})
예제 #9
0
    def __init__(self,
                 input_path=None,
                 name='temperature',
                 colors=None,
                 interval=6.0):
        self.input_path = self._find_temp_input(input_path)
        self.gpu = self._get_gpu()
        monitor.defmonitor(self._monitor_action,
                           name=name,
                           colors=colors,
                           interval=interval)

        def click_event(button):
            real_name = monitor.monitors[name].button.real_name
            return Match('RightBarClick', button, real_name)

        events.bind({click_event(_): lambda *a: self._toggle_dialog(name)})
예제 #10
0
    def __init__(self, name='clock', colors=None,
            interval=2.0, format='%Y-%m-%d w%V %H:%M'):
        self.format = format
        self.calendar_process = None
        monitor.defmonitor(self._monitor_action,
                name = name,
                colors = colors,
                interval = interval)

        def click_event(button):
            real_name = monitor.monitors[name].button.real_name
            return Match('RightBarClick', button, real_name)

        events.bind({
            click_event('1'): lambda *a: self.toggle_calendar(),
            click_event('3'): lambda *a: self.toggle_tz_time_dialog(name)
        })
예제 #11
0
    def __init__(self, name='work', colors=None, interval=60.0, path=None):
        self.interval = interval
        if not path:
            path = os.path.join(confpath[0], 'track')
        if not os.path.isdir(path):
            os.makedirs(path)
        self.path = path
        self.button = Button('right', name, colors)
        self.lock_proc = None
        self.lock_proc_lock = Lock()  # oh the imagination
        self.work_time = work_time.WorkTime(self._today())
        self.active = True
        self.track('STARTED')

        def click_event(button):
            real_name = self.button.real_name
            return Match('RightBarClick', button, real_name)

        events.bind({click_event('1'): lambda *a: self._toggle_dialog(name)})
예제 #12
0
    def __init__(self, bat_path=None, ac_path=None,
            name='battery', colors=None, interval=4.0):
        self.bat_capacity_path = _find_path(bat_path, _BAT_CAPACITY)
        self.bat_current_now_path = _find_path(bat_path, _BAT_CURRENT_NOW)
        self.bat_charge_now_path = _find_path(bat_path, _BAT_CHARGE_NOW)
        self.bat_charge_full_path = _find_path(bat_path, _BAT_CHARGE_FULL)
        self.bat_status_path = _find_path(bat_path, _BAT_STATUS)
        self.ac_online_path = _find_path(ac_path, _AC_ONLINE)
        self.current_avg = deque(maxlen=_CURRENT_AVG_SAMPLES)
        self.warned = False
        monitor.defmonitor(self._monitor_action,
                name = name,
                colors = colors,
                interval = interval)
        if not colors: colors = wmii.cache['normcolors']
        self.colors = self.normcolors = colors

        def click_event(button):
            real_name = monitor.monitors[name].button.real_name
            return Match('RightBarClick', button, real_name)

        events.bind({
            click_event(_): lambda *a: self._toggle_dialog(name)
        })