diff --git a/Documents/bin/nc-notify b/Documents/bin/nc-notify new file mode 100755 index 0000000000000000000000000000000000000000..62a270d24669e42b045b380e0cf82c49e6b554a1 --- /dev/null +++ b/Documents/bin/nc-notify @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# pylint: disable=invalid-name +"""Send a notification to my notification service. + +Send it in a separate process so that the calling process is not hanged. +""" + +import json +import os +import sys +import urllib.request + + +if __name__ == "__main__": + if os.fork(): + sys.exit() + message = " ".join(sys.argv[1:]) + data = json.dumps({"message": message}).encode() + request = urllib.request.Request( + "https://notify.shore.co.il/send", + data=data, + method="POST", + headers={"Content-Type": "application/json"}, + ) + urllib.request.urlopen(request) # nosec diff --git a/Documents/bin/notify b/Documents/bin/notify index c5551b2ebfcb0e759278f9d7b11b54b0649e8b38..c2ce2d3b47d868cd0680dad302bbdfd07bed9ff9 100755 --- a/Documents/bin/notify +++ b/Documents/bin/notify @@ -16,7 +16,7 @@ notify_send () { nextcloud () { message="$(cat)" - curl --silent -d "$message" https://notify.shore.co.il/send > /dev/null + nc-notify "$message" } # Try hostname if present.