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 logging
import os import os
import sys import sys
from subprocess import PIPE, Popen
from typing import List from typing import List
import requests import requests
@ -190,9 +191,26 @@ def add_url(config, url):
# TODO: check auth error handling # TODO: check auth error handling
return None, r.status_code == 401 return None, r.status_code == 401
send_notification(url)
return r.json(), False 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__": if __name__ == "__main__":
sysargs = sys.argv sysargs = sys.argv
urls = sysargs[1:] urls = sysargs[1:]