diff --git a/ui/opensnitch/config.py b/ui/opensnitch/config.py index be96b8d3..a05345d9 100644 --- a/ui/opensnitch/config.py +++ b/ui/opensnitch/config.py @@ -8,6 +8,7 @@ class Config: HELP_RULES_URL = "https://github.com/evilsocket/opensnitch/wiki/Rules" HELP_SYS_RULES_URL = "https://github.com/evilsocket/opensnitch/wiki/System-rules" HELP_CONFIG_URL = "https://github.com/evilsocket/opensnitch/wiki/Configurations" + HELP_SYSTRAY_WARN = "https://github.com/evilsocket/opensnitch/wiki/Known-problems#opensnitch-icon-does-not-show-up-on-gnome-shell" OPERAND_PROCESS_ID = "process.id" OPERAND_PROCESS_PATH = "process.path" @@ -101,6 +102,7 @@ class Config: DEFAULT_POPUP_ADVANCED_DSTPORT = "global/default_popup_advanced_dstport" DEFAULT_POPUP_ADVANCED_UID = "global/default_popup_advanced_uid" DEFAULT_SERVER_ADDR = "global/server_address" + DEFAULT_HIDE_SYSTRAY_WARN = "global/hide_systray_warning" DEFAULT_DB_TYPE_KEY = "database/type" DEFAULT_DB_FILE_KEY = "database/file" DEFAULT_DB_PURGE_OLDEST = "database/purge_oldest" diff --git a/ui/opensnitch/service.py b/ui/opensnitch/service.py index e4d0ec7b..db3dbab6 100644 --- a/ui/opensnitch/service.py +++ b/ui/opensnitch/service.py @@ -1,4 +1,5 @@ from PyQt5 import QtWidgets, QtGui, QtCore +from PyQt5.QtCore import QCoreApplication as QC from datetime import datetime, timedelta from threading import Thread, Lock, Event @@ -193,10 +194,29 @@ class UIService(ui_pb2_grpc.UIServicer, QtWidgets.QGraphicsObject): gui = self._stats_dialog def __show_gui(): if not tray.isSystemTrayAvailable(): + self._show_systray_msg_error() gui.show() QtCore.QTimer.singleShot(10000, __show_gui) + def _show_systray_msg_error(self): + print("") + print("WARNING: system tray not available. On GNOME you need the extension gnome-shell-extension-appindicator.") + print("\tRead more:", Config.HELP_SYSTRAY_WARN) + print("") + + hide_msg = self._cfg.getBool(Config.DEFAULT_HIDE_SYSTRAY_WARN) + if hide_msg: + return + self._desktop_notifications.show( + QC.translate("stats", "WARNING"), + QC.translate("stats", """System tray not available. Read more: +{0} +""".format(Config.HELP_SYSTRAY_WARN)), + os.path.join(self._path, "res/icon-white.svg") + ) + self._cfg.setSettings(Config.DEFAULT_HIDE_SYSTRAY_WARN, True) + def _on_tray_icon_activated(self, reason): if reason == QtWidgets.QSystemTrayIcon.Trigger or reason == QtWidgets.QSystemTrayIcon.MiddleClick: if self._stats_dialog.isVisible() and not self._stats_dialog.isMinimized():