From e1d13f9905c7194077b7c2a2ce21ead9bfa41828 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 29 Jul 2019 11:26:07 -0300 Subject: [PATCH 1/2] enable / disable tray and update-check daemon --- CHANGELOG.md | 4 ++++ README.md | 1 + fpakman/app.py | 31 ++++++++++++++++++++++--------- fpakman/view/qt/systray.py | 20 ++++---------------- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aff5f71..6a42b4e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.4.3] +### Improvements +- new environment variable / argument to enable / disable the tray icon and update-check daemon: FPAKMAN_TRAY (--tray) + ## [0.4.2] - 2019-07-28 ### Improvements - showing a warning dialog when the application starts and **snapd** is unavailable diff --git a/README.md b/README.md index 861a341a..c8f022b3 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ You can change some application settings via environment variables or arguments - **FPAKMAN_FLATPAK**: enables / disables flatpak usage. Use **0** (disable) or **1** (enabled, default) - **FPAKMAN_SNAP**: enables / disables snap usage. Use **0** (disable) or **1** (enabled, default) - **FPAKMAN_CHECK_PACKAGING_ONCE**: If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Use **0** (disable, default) or **1** (enable). +- **FPAKMAN_TRAY**: If the tray icon and update-check daemon should be created. Use **0** (disable) or **1** (enable, default). ### How to improve the application performance - If you don't care about a specific packaging technology and don't want **fpakman** to deal with it, just disable it via the specific argument or environment variable. For instance, if I don't care diff --git a/fpakman/app.py b/fpakman/app.py index ed8ad245..c48a8f8b 100755 --- a/fpakman/app.py +++ b/fpakman/app.py @@ -23,6 +23,7 @@ from fpakman.util.cache import Cache from fpakman.util.memory import CacheCleaner from fpakman.view.qt import dialog from fpakman.view.qt.systray import TrayIcon +from fpakman.view.qt.window import ManageWindow def log_msg(msg: str, color: int = None): @@ -45,6 +46,7 @@ parser.add_argument('-di', '--download-icons', action="store", choices=[0, 1], d parser.add_argument('--flatpak', action="store", default=os.getenv('FPAKMAN_FLATPAK', 1), choices=[0, 1], type=int, help='Enables / disables flatpak usage. Default: %(default)s') parser.add_argument('--snap', action="store", default=os.getenv('FPAKMAN_SNAP', 1), choices=[0, 1], type=int, help='Enables / disables snap usage. Default: %(default)s') parser.add_argument('-co', '--check-packaging-once', action="store", default=os.getenv('FPAKMAN_CHECK_PACKAGING_ONCE', 0), choices=[0, 1], type=int, help='If the available supported packaging types should be checked ONLY once. It improves the application speed if enabled, but can generate errors if you uninstall any packaging technology while using it, and every time a supported packaging type is installed it will only be available after a restart. Default: %(default)s') +parser.add_argument('--tray', action="store", default=os.getenv('FPAKMAN_TRAY', 1), choices=[0, 1], type=int, help='If the tray icon and update-check daemon should be created. Default: %(default)s') args = parser.parse_args() if args.cache_exp < 0: @@ -112,16 +114,27 @@ app.setApplicationName(__app_name__) app.setApplicationVersion(__version__) app.setWindowIcon(QIcon(resource.get_path('img/logo.svg'))) -trayIcon = TrayIcon(locale_keys=locale_keys, - manager=manager, - check_interval=args.check_interval, - icon_cache=icon_cache, - disk_cache=args.disk_cache, - update_notification=bool(args.update_notification), - download_icons=args.download_icons, - screen_size=app.primaryScreen().size()) +screen_size = app.primaryScreen().size() -trayIcon.show() +manage_window = ManageWindow(locale_keys=locale_keys, + manager=manager, + icon_cache=icon_cache, + disk_cache=args.disk_cache, + download_icons=bool(args.download_icons), + screen_size=screen_size) + +if args.tray: + trayIcon = TrayIcon(locale_keys=locale_keys, + manager=manager, + manage_window=manage_window, + check_interval=args.check_interval, + update_notification=bool(args.update_notification)) + + manage_window.tray_icon = trayIcon + trayIcon.show() +else: + manage_window.refresh_apps() + manage_window.show() CacheCleaner(caches).start() diff --git a/fpakman/view/qt/systray.py b/fpakman/view/qt/systray.py index 463ef181..df4f0450 100755 --- a/fpakman/view/qt/systray.py +++ b/fpakman/view/qt/systray.py @@ -2,7 +2,7 @@ import time from threading import Lock, Thread from typing import List -from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt, QSize +from PyQt5.QtCore import QThread, pyqtSignal, QCoreApplication, Qt from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QSystemTrayIcon, QMenu @@ -10,7 +10,6 @@ from fpakman import __app_name__ from fpakman.core import resource, system from fpakman.core.controller import ApplicationManager from fpakman.core.model import ApplicationUpdate -from fpakman.util.cache import Cache from fpakman.view.qt.about import AboutDialog from fpakman.view.qt.window import ManageWindow @@ -34,14 +33,10 @@ class UpdateCheck(QThread): class TrayIcon(QSystemTrayIcon): - def __init__(self, locale_keys: dict, manager: ApplicationManager, icon_cache: Cache, disk_cache: bool, download_icons: bool, screen_size: QSize, check_interval: int = 60, update_notification: bool = True): + def __init__(self, locale_keys: dict, manager: ApplicationManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True): super(TrayIcon, self).__init__() self.locale_keys = locale_keys self.manager = manager - self.icon_cache = icon_cache - self.disk_cache = disk_cache - self.download_icons = download_icons - self.screen_size = screen_size self.icon_default = QIcon(resource.get_path('img/logo.png')) self.icon_update = QIcon(resource.get_path('img/logo_update.png')) @@ -73,6 +68,8 @@ class TrayIcon(QSystemTrayIcon): self.activated.connect(self.handle_click) self.set_default_tooltip() + self.manage_window = manage_window + def set_default_tooltip(self): self.setToolTip('{} ({})'.format(self.locale_keys['manage_window.title'], __app_name__).lower()) @@ -116,15 +113,6 @@ class TrayIcon(QSystemTrayIcon): self.lock_notify.release() def show_manage_window(self): - if self.manage_window is None: - self.manage_window = ManageWindow(locale_keys=self.locale_keys, - manager=self.manager, - icon_cache=self.icon_cache, - tray_icon=self, - disk_cache=self.disk_cache, - download_icons=self.download_icons, - screen_size=self.screen_size) - if self.manage_window.isMinimized(): self.manage_window.setWindowState(Qt.WindowNoState) elif not self.manage_window.isVisible(): From aacd0c72d65e2f8f0da1115078936997256b47db Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 29 Jul 2019 11:33:13 -0300 Subject: [PATCH 2/2] new AUR desktop entries --- aur/desktop_entry.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/aur/desktop_entry.py b/aur/desktop_entry.py index 05804aac..f54498d1 100644 --- a/aur/desktop_entry.py +++ b/aur/desktop_entry.py @@ -6,15 +6,20 @@ from pathlib import Path desktop_file = """ [Desktop Entry] Type = Application -Name = fpakman +Name = fpakman ({desc}) Categories = System; Comment = Manage your Flatpak / Snap applications -Exec = /usr/bin/fpakman +Exec = /usr/bin/fpakman{param} Icon = /usr/lib/python{version}/site-packages/fpakman/resources/img/logo.svg -""".format(version="{}.{}".format(sys.version_info.major, sys.version_info.minor)) +""" + +py_version = "{}.{}".format(sys.version_info.major, sys.version_info.minor) with open('fpakman.desktop', 'w+') as f: - f.write(desktop_file) + f.write(desktop_file.format(desc='panel', version=py_version, param=' --tray 0')) + +with open('fpakman_tray.desktop', 'w+') as f: + f.write(desktop_file.format(desc='tray', version=py_version, param='')) # cleaning the old fpakman.desktop entry model -> the following lines will be removed for the next releases