@@ 1,10 1,11 @@
-import asyncio
-import socket
import argparse
+import asyncio
+import datetime
+import json
import os
+import signal
+import socket
import sys
-import json
-import datetime
import xdg.BaseDirectory
@@ 96,16 97,30 @@ def main():
if args.cmd == "bind":
stop = asyncio.Event()
- async def go():
+ async def act():
stop.set()
- action = Action(name=args.action, coro=go)
+ class Exit:
+ def __init__(self):
+ self.status = 0
+
+ def interrupt(self):
+ self.status = 1
+ stop.set()
+ ec = Exit()
+
+ action = Action(name=args.action, coro=act)
async def main():
+ loop = asyncio.get_running_loop()
+
+ loop.add_signal_handler(signal.SIGINT, ec.interrupt)
+
await action.bind(socket_path)
await stop.wait()
asyncio.run(main())
+ sys.exit(ec.status)
elif args.cmd == "trigger":
msg = {