1 Commits
3.0.1 ... 3.0.2

Author SHA1 Message Date
d2e03f89ca Add desktop notifications 2023-04-29 21:28:42 +02:00
2 changed files with 16 additions and 2 deletions

View File

@ -13,7 +13,8 @@ license=('GPL3')
makedepends=('git') makedepends=('git')
depends=('python3' depends=('python3'
'rsync' 'rsync'
'python-dotenv') 'python-dotenv'
'python-dbus')
install=${pkgname}.install install=${pkgname}.install
source=(git+https://github.com/Fuxino/${pkgname}.git) source=(git+https://github.com/Fuxino/${pkgname}.git)
sha256sums=('SKIP') sha256sums=('SKIP')

View File

@ -4,6 +4,7 @@
from dotenv import load_dotenv from dotenv import load_dotenv
import os import os
from functools import wraps from functools import wraps
import dbus
from shutil import rmtree from shutil import rmtree
import argparse import argparse
import configparser import configparser
@ -211,6 +212,10 @@ class Backup:
if self._err_flag: if self._err_flag:
logger.warning('Some errors occurred (check log for details)') logger.warning('Some errors occurred (check log for details)')
return 1
return 0
def _parse_arguments(): def _parse_arguments():
parser = argparse.ArgumentParser(prog='simple_backup', parser = argparse.ArgumentParser(prog='simple_backup',
@ -275,7 +280,15 @@ def simple_backup():
backup = Backup(inputs, output, exclude, keep, backup_options) backup = Backup(inputs, output, exclude, keep, backup_options)
if backup.check_params(): if backup.check_params():
backup.run() obj = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
obj = dbus.Interface(obj, "org.freedesktop.Notifications")
obj.Notify("simple_backup", 0, "", "Starting backup...", "", [], {"urgency": 1}, 10000)
status = backup.run()
if status == 0:
obj.Notify("simple_backup", 0, "", "Backup finished.", "", [], {"urgency": 1}, 10000)
else:
obj.Notify("simple_backup", 0, "", "Backup finished. Some errors occurred.", "", [], {"urgency": 1}, 10000)
if __name__ == '__main__': if __name__ == '__main__':