add notification

This commit is contained in:
ksyasuda 2022-07-22 01:53:17 -07:00
parent 7a686e5877
commit 95f45e8435

View File

@ -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:]