From 95f45e8435dc3193b2d05f993b5942f79f4214ba Mon Sep 17 00:00:00 2001 From: ksyasuda Date: Fri, 22 Jul 2022 01:53:17 -0700 Subject: [PATCH] add notification --- wallabag-add.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wallabag-add.py b/wallabag-add.py index b153c07..b63f178 100755 --- a/wallabag-add.py +++ b/wallabag-add.py @@ -4,6 +4,7 @@ import json import logging import os import sys +from subprocess import PIPE, Popen from typing import List import requests @@ -190,9 +191,26 @@ def add_url(config, url): # TODO: check auth error handling return None, r.status_code == 401 + send_notification(url) return r.json(), False +def send_notification(url): + """Send a notification to the user using dunstify.""" + try: + Popen( + [ + "dunstify", + "-i", + "~/.local/share//icons//wallabag.svg", + "wallabag-add.py:", + "Added {}".format(url), + ] + ) + except Exception: + logger.error("Error while sending notification", exc_info=True) + + if __name__ == "__main__": sysargs = sys.argv urls = sysargs[1:]