def test_multiple_sockets(self): socket1 = i3.Socket() socket2 = i3.Socket() socket3 = i3.Socket() for socket in [socket1, socket2, socket3]: self.test_response(socket) for socket in [socket1, socket2, socket3]: socket.close()
def reinit_socket(self): self.close() time.sleep(2) event_socket = i3.Socket() self.event_socket = event_socket self.event_socket.subscribe(self.event_type, self.event) data_socket = i3.Socket() self.data_socket = data_socket self.subscribed = True
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')
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')
def main(socket, type, timeout, message): """ Excepts arguments and evaluates them. """ if not socket: socket = i3.get_socket_path() if not socket: print("Couldn't get socket path. Are you sure i3 is running?") return False # Initializes default socket with given path and timeout try: i3.default_socket(i3.Socket(path=socket, timeout=timeout)) except i3.ConnectionError: print("Couldn't connect to socket at '%s'." % socket) return False # Format input if type in i3.EVENT_TYPES: event_type = type event = message type = 'subscribe' elif type == 'subscribe': message = message.split(' ') message_len = len(message) if message_len >= 1: event_type = message[0] if message_len >= 2: event = ' '.join(message[1:]) else: event = '' else: # Let if fail event_type = '' try: if type == 'subscribe': i3.subscribe(event_type, event) else: output = i3.msg(type, message) print(output) except i3.i3Exception as i3error: print(i3error)
#!/usr/bin/python import colorsys import os import random import subprocess from openrazer.client import DeviceManager from openrazer.client import constants as razer_constants import i3 import time device_manager = DeviceManager() device_manager.sync_effects = False i3socket = i3.Socket() if not os.path.exists("/etc/rasiel/keyboardrasiel"): os.mkfifo("/etc/rasiel/keyboardrasiel") try: pipe = [open("/etc/rasiel/keyboardrasiel", "r")] except: print("Failed opening pipe") pipe.close() quit() red = (255, 0, 0) greenplus = (60, 255, 20) green = (0, 255, 0) lightgreen = (55, 255, 55) darkgreen = (0, 10, 0) blue = (0, 0, 255) cyan = (0, 255, 255)
def connect(): return i3.Socket('/nil/2971.socket')