Lots of changes

This commit is contained in:
2021-06-16 14:48:44 +02:00
parent 97389199f5
commit a493042a98
14 changed files with 39 additions and 6 deletions

30
lunkd.py Normal file
View File

@@ -0,0 +1,30 @@
import asyncio
import websockets
import subprocess
IP = 'localhost'
PORT = 40022
def run_command(cmd):
completedProcess = subprocess.run(cmd, shell=True)
if completedProcess.stdout:
print('Output:')
print(completedProcess.stdout)
if completedProcess.stderr:
print('Error:')
print(completedProcess.stderr)
async def ws_server(websocket, path):
while True:
cmd = await websocket.recv()
print(cmd)
run_command(f'notify-send -t 3000 "Command recieved:\n{cmd}"')
run_command(cmd)
if __name__ == '__main__':
start_server = websockets.serve(ws_server, IP, PORT)
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()