diff --git a/BUILDING.md b/BUILDING.md index 3fb8b8b..76ec7f5 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -7,6 +7,16 @@ $ pip install -r requirements.txt $ pip install pyinstaller ``` +**Alternative: System packages (Debian/Ubuntu)** + +If you prefer to use system packages instead of pip, install the required PyQt6 packages: + +```shell +$ apt install python3-pyqt6 python3-pyqt6.qtwebsockets python3-pyqt6.qtmultimedia +``` + +Note: This may require specific Python versions and may not include the latest features. + Currently it's only possible to create installer packages from the pyinstaller output. For any target platform, first create the executable with pyinstaller: ```shell diff --git a/gotify-tray.spec b/gotify-tray.spec index 396da10..4dd2fbc 100644 --- a/gotify-tray.spec +++ b/gotify-tray.spec @@ -8,7 +8,7 @@ logo = "gotify_tray/gui/images/logo.ico" if platform.system() != "Darwin" else " a = Analysis(['gotify_tray/__main__.py'], pathex=[os.getcwd()], - binaries=[('/lib/x86_64-linux-gnu/libpython3.10.so', '.'), ('/lib/x86_64-linux-gnu/libpython3.10.so.1', '.')], + binaries=[('/lib/x86_64-linux-gnu/libpython3.12.so', '.'), ('/lib/x86_64-linux-gnu/libpython3.12.so.1', '.')], datas=[('gotify_tray/gui/images', 'gotify_tray/gui/images'), ('gotify_tray/gui/themes', 'gotify_tray/gui/themes')], hiddenimports=[], hookspath=[], diff --git a/gotify_tray/__main__.py b/gotify_tray/__main__.py index a5023f5..5aa3175 100644 --- a/gotify_tray/__main__.py +++ b/gotify_tray/__main__.py @@ -1,11 +1,21 @@ def main(): + import os import sys if "--version" in sys.argv: from gotify_tray.__version__ import __version__ + print(__version__) else: + # Check for display before importing GUI modules + if not os.environ.get("DISPLAY"): + print( + "Error: No display environment detected. This application requires a graphical desktop environment to run.", + file=sys.stderr, + ) + sys.exit(1) from gotify_tray.gui import start_gui + start_gui() diff --git a/gotify_tray/gui/MainApplication.py b/gotify_tray/gui/MainApplication.py index 917ddb8..4bb38ab 100644 --- a/gotify_tray/gui/MainApplication.py +++ b/gotify_tray/gui/MainApplication.py @@ -459,9 +459,10 @@ class MainApplication(QtWidgets.QApplication): self.main_window.hidden.connect(self.main_window_hidden_callback) self.main_window.activated.connect(self.tray.revert_icon) - self.styleHints().colorSchemeChanged.connect( - self.theme_change_requested_callback - ) + if hasattr(self.styleHints(), "colorSchemeChanged"): + self.styleHints().colorSchemeChanged.connect( + self.theme_change_requested_callback + ) self.messages_model.rowsInserted.connect( self.main_window.display_message_widgets diff --git a/gotify_tray/gui/designs/widget_main.py b/gotify_tray/gui/designs/widget_main.py index 4883949..a51b823 100644 --- a/gotify_tray/gui/designs/widget_main.py +++ b/gotify_tray/gui/designs/widget_main.py @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_main.ui' # -# Created by: PyQt6 UI code generator 6.9.1 +# Created by: PyQt6 UI code generator 6.10.0 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. diff --git a/gotify_tray/gui/designs/widget_message.py b/gotify_tray/gui/designs/widget_message.py index ed0d5fa..e37540b 100644 --- a/gotify_tray/gui/designs/widget_message.py +++ b/gotify_tray/gui/designs/widget_message.py @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_message.ui' # -# Created by: PyQt6 UI code generator 6.9.1 +# Created by: PyQt6 UI code generator 6.10.0 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. diff --git a/gotify_tray/gui/designs/widget_server.py b/gotify_tray/gui/designs/widget_server.py index 8e84961..408b4ac 100644 --- a/gotify_tray/gui/designs/widget_server.py +++ b/gotify_tray/gui/designs/widget_server.py @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_server.ui' # -# Created by: PyQt6 UI code generator 6.9.1 +# Created by: PyQt6 UI code generator 6.10.0 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. diff --git a/gotify_tray/gui/designs/widget_settings.py b/gotify_tray/gui/designs/widget_settings.py index 7056ed2..5dd120e 100644 --- a/gotify_tray/gui/designs/widget_settings.py +++ b/gotify_tray/gui/designs/widget_settings.py @@ -1,6 +1,6 @@ # Form implementation generated from reading ui file 'gotify_tray/gui/designs/widget_settings.ui' # -# Created by: PyQt6 UI code generator 6.9.1 +# Created by: PyQt6 UI code generator 6.10.0 # # WARNING: Any manual changes made to this file will be lost when pyuic6 is # run again. Do not edit this file unless you know what you are doing. diff --git a/gotify_tray/gui/models/MessagesModel.py b/gotify_tray/gui/models/MessagesModel.py index a7da27a..d90f9b6 100644 --- a/gotify_tray/gui/models/MessagesModel.py +++ b/gotify_tray/gui/models/MessagesModel.py @@ -65,7 +65,7 @@ class MessagesProxyModel(QtCore.QSortFilterProxyModel): return False if self.text_filter: title = (message.title or "").lower() - msg = message.message.lower() + msg = (message.message or "").lower() if self.text_filter not in title and self.text_filter not in msg: return False return True diff --git a/gotify_tray/gui/themes/__init__.py b/gotify_tray/gui/themes/__init__.py index f8bc09a..87bb332 100644 --- a/gotify_tray/gui/themes/__init__.py +++ b/gotify_tray/gui/themes/__init__.py @@ -3,14 +3,21 @@ from gotify_tray.utils import get_abs_path themes = { - QtCore.Qt.ColorScheme.Dark: "dark", - QtCore.Qt.ColorScheme.Light: "light", - QtCore.Qt.ColorScheme.Unknown: "light", + 2: "dark", # Dark + 1: "light", # Light + 0: "light", # Unknown } def set_theme(app: QtWidgets.QApplication): - theme = themes.get(app.styleHints().colorScheme(), "light") + if hasattr(app.styleHints(), "colorScheme"): + color_scheme = app.styleHints().colorScheme() + theme = themes.get( + color_scheme.value if hasattr(color_scheme, "value") else color_scheme, + "light", + ) + else: + theme = "light" # Default to light theme if colorScheme not available stylesheet = "" with open(get_abs_path(f"gotify_tray/gui/themes/base.qss"), "r") as f: @@ -23,5 +30,12 @@ def set_theme(app: QtWidgets.QApplication): def get_theme_file(file: str) -> str: app = QtCore.QCoreApplication.instance() - theme = themes.get(app.styleHints().colorScheme(), "light") + if hasattr(app.styleHints(), "colorScheme"): + color_scheme = app.styleHints().colorScheme() + theme = themes.get( + color_scheme.value if hasattr(color_scheme, "value") else color_scheme, + "light", + ) + else: + theme = "light" # Default to light theme if colorScheme not available return get_abs_path(f"gotify_tray/gui/themes/{theme}/{file}") diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..35f2194 --- /dev/null +++ b/run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Check if virtual environment exists +if [ ! -d "venv" ]; then + echo "Creating virtual environment..." + python3 -m venv venv + echo "Installing dependencies..." + source venv/bin/activate + pip install -r requirements.txt +else + source venv/bin/activate +fi + +# Run the application +python -m gotify_tray \ No newline at end of file