Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 26 lines (23 sloc) 752 Bytes
#!/usr/bin/env python3
import json, socket, subprocess, threading, traceback
def client(clisock):
# assume it fits in a single packet
data = clisock.recv(4096).decode()
if data[0] == '{':
data = json.loads(data)
title, body = data['title'], data['body']
else:
data = data.split(' ', 1)
if len(data) == 1:
title, body = '', data
else:
title, body = data
# for Python 3.4
subprocess.call(['notify-send', '-a', title, '--', body])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
sock.bind(('127.0.0.1', 9010))
sock.listen(5)
while 1:
clisock, _ = sock.accept()
thr = threading.Thread(target=client, args=(clisock,), daemon=True)
thr.start()