diff --git a/CHANGELOG.md b/CHANGELOG.md index add81edd..532d8ef0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **Show button** for large fields in the **Info** window - New environment variables / parameters: BAUH_MAX_DISPLAYED and BAUH_LOGS - ### Improvements: - Reading installed Snaps now takes around 95% less time - Reading Snap suggestions now takes around 75% less time @@ -29,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Progress bar status can now be controlled by the software manager while an operation is being executed - Flatpak: showing runtime branches as versions when they are not available - small UI improvements +- Environment variable / parameter BAUH_UPDATE_NOTIFICATION renamed to BAUH_SYSTEM_NOTIFICATIONS and now works for any system notification ### UI Changes - **Upgrade selected** and **Refresh** buttons now have text labels and new colors diff --git a/README.md b/README.md index bbd753f2..f7c6731a 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ In order to autostart the application, use your Desktop Environment settings to ### Settings You can change some application settings via environment variables or arguments (type ```bauh --help``` to get more information). -- **BAUH_UPDATE_NOTIFICATION**: enable or disable system updates notifications. Use **0** (disable) or **1** (enable, default). +- **BAUH_SYSTEM_NOTIFICATIONS**: enable or disable system notifications. Use **0** (disable) or **1** (enable, default). - **BAUH_CHECK_INTERVAL**: define the updates check interval in seconds. Default: 60. - **BAUH_LOCALE**: define a custom app translation for a given locale key (e.g: 'pt', 'en', 'es', ...). Default: system locale. - **BAUH_CACHE_EXPIRATION**: define a custom expiration time in SECONDS for cached API data. Default: 3600 (1 hour). diff --git a/bauh/app.py b/bauh/app.py index 1d485ccf..2c49ebd2 100755 --- a/bauh/app.py +++ b/bauh/app.py @@ -61,14 +61,15 @@ def main(): suggestions=args.sugs, display_limit=args.max_displayed, config=user_config, - context=context) + context=context, + notifications=bool(args.system_notifications)) if args.tray: - tray_icon = TrayIcon(locale_keys=i18n, + tray_icon = TrayIcon(i18n=i18n, manager=manager, manage_window=manage_window, check_interval=args.check_interval, - update_notification=bool(args.update_notification),) + update_notification=bool(args.system_notifications)) manage_window.set_tray_icon(tray_icon) tray_icon.show() diff --git a/bauh/app_args.py b/bauh/app_args.py index e5b4b163..58f15af4 100644 --- a/bauh/app_args.py +++ b/bauh/app_args.py @@ -18,9 +18,9 @@ def read() -> Namespace: help='Translation key. Default: %(default)s') parser.add_argument('-i', '--check-interval', action="store", default=int(os.getenv('BAUH_CHECK_INTERVAL', 60)), type=int, help='Updates check interval in SECONDS. Default: %(default)s') - parser.add_argument('-n', '--update-notification', action="store", choices=[0, 1], - default=os.getenv('BAUH_UPDATE_NOTIFICATION', 1), type=int, - help='Enables / disables system notifications for new updates. Default: %(default)s') + parser.add_argument('-n', '--system-notifications', action="store", choices=[0, 1], + default=os.getenv('BAUH_SYSTEM_NOTIFICATIONS', 1), type=int, + help='Enables / disables system notifications. Default: %(default)s') parser.add_argument('-dc', '--disk-cache', action="store", choices=[0, 1], default=os.getenv('BAUH_DISK_CACHE', 1), type=int, help='Enables / disables disk cache. When disk cache is enabled, the installed applications data are loaded faster. Default: %(default)s') @@ -55,8 +55,8 @@ def validate(args: Namespace, logger: logging.Logger): logger.info("'check-interval' set as '{}'. It must be >= 0. Aborting...".format(args.check_interval)) exit(1) - if args.update_notification == 0: - logger.info('updates notifications are disabled') + if args.system_notifications == 0: + logger.info('system notifications are disabled') if args.download_icons == 0: logger.info("'download-icons' is disabled") diff --git a/bauh/view/qt/systray.py b/bauh/view/qt/systray.py index 65244752..0b5d1cab 100755 --- a/bauh/view/qt/systray.py +++ b/bauh/view/qt/systray.py @@ -33,9 +33,9 @@ class UpdateCheck(QThread): class TrayIcon(QSystemTrayIcon): - def __init__(self, locale_keys: dict, manager: SoftwareManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True): + def __init__(self, i18n: dict, manager: SoftwareManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True): super(TrayIcon, self).__init__() - self.locale_keys = locale_keys + self.i18n = i18n self.manager = manager self.icon_default = QIcon(resource.get_path('img/logo.png')) @@ -44,13 +44,13 @@ class TrayIcon(QSystemTrayIcon): self.menu = QMenu() - self.action_manage = self.menu.addAction(self.locale_keys['tray.action.manage']) + self.action_manage = self.menu.addAction(self.i18n['tray.action.manage']) self.action_manage.triggered.connect(self.show_manage_window) - self.action_about = self.menu.addAction(self.locale_keys['tray.action.about']) + self.action_about = self.menu.addAction(self.i18n['tray.action.about']) self.action_about.triggered.connect(self.show_about) - self.action_exit = self.menu.addAction(self.locale_keys['tray.action.exit']) + self.action_exit = self.menu.addAction(self.i18n['tray.action.exit']) self.action_exit.triggered.connect(lambda: QCoreApplication.exit()) self.setContextMenu(self.menu) @@ -71,7 +71,7 @@ class TrayIcon(QSystemTrayIcon): self.manage_window = manage_window def set_default_tooltip(self): - self.setToolTip('{} ({})'.format(self.locale_keys['manage_window.title'], __app_name__).lower()) + self.setToolTip('{} ({})'.format(self.i18n['manage_window.title'], __app_name__).lower()) def handle_click(self, reason): if reason == self.Trigger: @@ -95,7 +95,8 @@ class TrayIcon(QSystemTrayIcon): if update_keys.difference(self.last_updates): self.last_updates = update_keys - msg = '{}: {}'.format(self.locale_keys['notification.new_updates'], len(updates)) + n_updates = len(updates) + msg = self.i18n['notification.update{}'.format('' if n_updates == 1 else 's')].format(n_updates) self.setToolTip(msg) if self.update_notification and notify_user: @@ -122,7 +123,7 @@ class TrayIcon(QSystemTrayIcon): def show_about(self): if self.dialog_about is None: - self.dialog_about = AboutDialog(self.locale_keys) + self.dialog_about = AboutDialog(self.i18n) if self.dialog_about.isHidden(): self.dialog_about.show() diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 9a437fa3..12e7234f 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -44,8 +44,9 @@ class ManageWindow(QWidget): signal_user_res = pyqtSignal(bool) signal_table_update = pyqtSignal() - def __init__(self, i18n: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, download_icons: bool, - screen_size, suggestions: bool, display_limit: int, config: Configuration, context: ApplicationContext, tray_icon=None): + def __init__(self, i18n: dict, icon_cache: MemoryCache, manager: SoftwareManager, disk_cache: bool, + download_icons: bool, screen_size, suggestions: bool, display_limit: int, config: Configuration, + context: ApplicationContext, notifications: bool, tray_icon=None): super(ManageWindow, self).__init__() self.i18n = i18n self.manager = manager @@ -61,6 +62,7 @@ class ManageWindow(QWidget): self.screen_size = screen_size self.config = config self.context = context + self.notifications = notifications self.icon_app = QIcon(resource.get_path('img/logo.svg')) self.resize(ManageWindow.__BASE_HEIGHT__, ManageWindow.__BASE_HEIGHT__) @@ -457,7 +459,7 @@ class ManageWindow(QWidget): self.checkbox_console.setChecked(True) def _can_notify_user(self): - return self.isHidden() or self.isMinimized() + return self.notifications and (self.isHidden() or self.isMinimized()) def _finish_downgrade(self, res: dict): self.finish_action() diff --git a/bauh/view/resources/locale/en b/bauh/view/resources/locale/en index 7c98f589..11af0fe5 100644 --- a/bauh/view/resources/locale/en +++ b/bauh/view/resources/locale/en @@ -49,7 +49,8 @@ tray.action.about=About tray.action.refreshing=Refreshing action.info.tooltip=Click here to see information about this application action.settings.tooltip=Click here to open extra actions -notification.new_updates=Updates +notification.update={} available update +notification.updates={} available updates notification.update_selected.success=app(s) updated successfully notification.update_selected.failed=Update failed notification.install.failed=installation failed diff --git a/bauh/view/resources/locale/es b/bauh/view/resources/locale/es index 8693be76..859f3f8c 100644 --- a/bauh/view/resources/locale/es +++ b/bauh/view/resources/locale/es @@ -51,7 +51,8 @@ tray.action.about=Sobre tray.action.refreshing=Recargando action.info.tooltip=Haga clic aquí para ver informaciones sobre este aplicativo action.settings.tooltip=Haga clic aquí para abrir acciones adicionales -notification.new_updates=Actualizaciones +notification.update={} actualización disponible +notification.updates={} actualizaciones disponibles notification.update_selected.success=aplicativo(s) actualizado(s) con éxito notification.update_selected.failed=La actualización falló notification.install.failed=la instalación ha fallado diff --git a/bauh/view/resources/locale/pt b/bauh/view/resources/locale/pt index 2f7ab916..50e478af 100644 --- a/bauh/view/resources/locale/pt +++ b/bauh/view/resources/locale/pt @@ -49,7 +49,8 @@ tray.action.manage=Gerenciar aplicativos tray.action.exit=Fechar tray.action.about=Sobre tray.action.refreshing=Recarregando -notification.new_updates=Atualizações +notification.update={} atualização disponível +notification.updates={} atualizações disponíveis notification.update_selected.success=aplicativo(s) atualizado(s) com sucesso notification.update_selected.failed=Erro ao atualizar notification.install.failed=instalação falhou