Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import struct
- import time
- import threading
- import math
- import os
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.connect(os.environ['SWAYSOCK'])
- def monitor():
- while True:
- hdr = s.recv(14)
- assert hdr[0:6] == b"i3-ipc"
- len, type = struct.unpack("@2I", hdr[6:])
- print(s.recv(len))
- threading.Thread(target=monitor).start()
- start = time.time()
- while True:
- theta = 2*math.pi*(time.time() - start)
- print(theta % (2*math.pi))
- x = round(500 + 300*math.cos(theta))
- y = round(500 + 300*math.sin(theta))
- msg = b"seat seat0 cursor set %d %d" % (x, y)
- hdr = b"i3-ipc" + struct.pack("@2I", len(msg), 0)
- s.send(hdr)
- s.send(msg)
- time.sleep(0.01)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement