mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
ui: display warning if the systray is not available
Some DEs and WMs don't support systray icons. In this situation we display the GUI after 10s. However many users were confused about this behaviour, thinking that this delay displaying the GUI was a bug (#937). Hopefully with a warning to the terminal and the desktop will help them to know what's going on.
This commit is contained in:
parent
2b9b9ab166
commit
9d353102df
2 changed files with 22 additions and 0 deletions
|
@ -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"
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Add table
Reference in a new issue