summaryrefslogtreecommitdiff
path: root/scripts/sockets.py
blob: 802d5e6125f7104941ae7b93a5b2b815359edc74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import socket
import time
import os

cmd1 = """
{"action":"add","identifier":"preview","max_height":21,"max_width":118,"path":"/tmp/a.png","x":10,"y":15}
"""

cmd2 = """
{"action":"add","identifier":"preview","max_height":47,"max_width":118,"path":"/tmp/b.png","x":10,"y":15}
"""

cmd_exit = """
{"action":"remove","identifier":"preview"}
"""

s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
connected = False
while not connected:
    try:
        s.connect(f"/tmp/ueberzugpp-30468.socket")
        connected = True
    except Exception:
        time.sleep(0.05)

s.sendall(str.encode(cmd1 + "\n"))
time.sleep(2)
s.sendall(str.encode(cmd_exit + "\n"))
s.sendall(str.encode(cmd2 + "\n"))
time.sleep(2)
s.sendall(str.encode(cmd_exit + "\n"))
s.close()