示例#1
0
    def __init__(self):
        self.lp = launchpad.Launchpad()
        self.mode = 'a'
        self.lp.Open()
        try:
            self.json = self.read_json(CONFIG_FILE)
        except:  # TODO: find error thrown
            sys.exit(
                "The configuration file could not be found or was not in the format specified."
            )

        try:
            self.lp.LedAllOn(0)
        except AttributeError:
            sys.exit(
                "The launchpad is not plugged in. Please plug in the device and try again."
            )
        if self.lp.Open():

            # initial lighting
            self.workspace_control(False, i3.get_workspaces(), False)
            self.i3_menu(None, [0, 0], None)
            self.refresh_letter_buttons()
            self.refresh_grid()

            # subscribe to events
            self.button_monitor = Subscription(self.i3_menu, self.lp)
            self.workspace_monitor = i3.Subscription(self.workspace_control,
                                                     'workspace')
示例#2
0
    def __init__(self, config, theme):
        super().__init__(config, theme, [])

        self._autoupdate = util.format.asbool(self.parameter("autoupdate", True))
        self._needs_update = True

        try:
            i3.Subscription(self._output_update, "output")
        except:
            pass
示例#3
0
 def __init__(self, state=None):
     if state:
         self.state = state
     # socket
     self.socket = i3.Socket()
     # Output to console
     workspaces = self.socket.get('get_workspaces')
     outputs = self.socket.get('get_outputs')
     self.display(self.format(workspaces, outputs))
     # Subscribe to an event
     callback = lambda data, event, _: self.change(data, event)
     self.subscription = i3.Subscription(callback, 'workspace')
示例#4
0
    def __init__(self, engine, config):
        widgets = []
        self._engine = engine
        super(Module, self).__init__(engine, config, widgets)
        self._autoupdate = bumblebee.util.asbool(
            self.parameter("autoupdate", True))
        self._needs_update = True

        try:
            i3.Subscription(self._output_update, "output")
        except:
            pass
示例#5
0
    def __init__(self, config, theme):
        super().__init__(config, theme, [])

        self._exclude = tuple(util.format.aslist(self.parameter("exclude")))
        self._autoupdate = util.format.asbool(self.parameter("autoupdate", True))
        self._autotoggle = util.format.asbool(self.parameter("autotoggle", False))
        self._autotoggle_side = self.parameter("autotoggle_side", "right")

        self._connected_displays = []
        self._active_displays = []
        self._initialized = False

        try:
            i3.Subscription(self._output_update, "output")
        except Exception:
            pass
示例#6
0
 def __init__(self, colors=None, font=None, bar_cmd=None, bar_args=None):
     if colors:
         self.colors = colors
     if font:
         self.font = font
     if bar_cmd:
         self.dzen_command = bar_cmd
     if bar_args:
         self.bar_arguments = bar_args
     # Initialize bar application...
     args = [self.bar_command] + self.bar_arguments
     self.bar = subprocess.Popen(args, stdin=subprocess.PIPE)
     # ...and socket
     self.socket = i3.Socket()
     # Output to the bar right away
     workspaces = self.socket.get('get_workspaces')
     outputs = self.socket.get('get_outputs')
     self.display(self.format(workspaces, outputs))
     # Subscribe to an event
     callback = lambda data, event, _: self.change(data, event)
     self.subscription = i3.Subscription(callback, 'workspace')
        global lock
        with lock:
            for output, process, width in bars:
                process.stdin.write(
                    powerline.render(
                        mode=modes[0], width=width,
                        matcher_info=output).encode('utf-8') + b'\n')
                process.stdin.flush()

    def update(evt):
        modes[0] = evt.change
        render()

    render(reschedule=True)

    if args.i3:
        try:
            import i3ipc
        except ImportError:
            import i3
            i3.Subscription(lambda evt, data, sub: render(), 'workspace')
        else:
            conn = i3ipc.Connection()
            conn.on('workspace::focus', lambda conn, evt: render())
            conn.on('mode', lambda conn, evt: update(evt))
            conn.main()

    while True:
        time.sleep(1e8)
示例#8
0
if __name__ == '__main__':
    name = 'wm'
    if len(sys.argv) > 1:
        name = sys.argv[1]

    powerline = Powerline(name, renderer_module='i3bar')
    powerline.update_renderer()

    interval = 0.5

    print('{"version": 1, "custom_workspace": true}')
    print('[')
    print('\t[[],[]]')

    lock = Lock()

    def render(event=None, data=None, sub=None):
        global lock
        with lock:
            s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n'
            s += ',[\n' + powerline.render(side='left')[:-2] + '\n]'
            print(',[\n' + s + '\n]')
            sys.stdout.flush()

    sub = i3.Subscription(render, 'workspace')

    while True:
        start_time = monotonic()
        render()
        time.sleep(max(interval - (monotonic() - start_time), 0.1))
示例#9
0
            print(props['title'])
            # if exact match then notifcation has been cleared
            if props['title'] == 'Telegram':
                cmd = [
                    'wmctrl', '-b', 'remove,demands_attention', '-r',
                    TELEGRAMINSTANCE, '-x'
                ]
                print('Request removal')
                subprocess.Popen(cmd)
            else:
                if not ws['container']['urgent']:
                    cmd = [
                        'wmctrl', '-b', 'add,demands_attention', '-r',
                        TELEGRAMINSTANCE, '-x'
                    ]
                    print('Request adding')
                    subprocess.Popen(cmd)


socketpath = i3.get_socket_path()
if not os.path.exists(socketpath):
    print('I3 is not running')
    sys.exit(3)

try:
    i3.Subscription(workspacechange, 'workspace')
    i3.Subscription(windowchange, 'window')
except Exception as e:
    print('Failed', e)
    sys.exit(4)
示例#10
0
	def render(reschedule=False):
		if reschedule:
			Timer(0.5, render, kwargs={'reschedule': True}).start()

		global lock
		with lock:
			write(powerline.render(mode=modes[0]))
			write('\n')
			sys.stdout.flush()

	def update(evt):
		modes[0] = evt.change
		render()

	render(reschedule=True)

	if args.i3:
		try:
			import i3ipc
		except ImportError:
			import i3
			i3.Subscription(lambda evt, data, sub: print(render()), 'workspace')
		else:
			conn = i3ipc.Connection()
			conn.on('workspace::focus', lambda conn, evt: render())
			conn.on('mode', lambda conn, evt: update(evt))
			conn.main()

	while True:
		time.sleep(1e8)