Fixes GTK4 Layer Shell and Ollama integration issues

Addresses multiple issues related to GTK4 Layer Shell initialization and Ollama integration.

- Reorders initialization to ensure the layer shell is set up before window properties.
- Adds error detection for layer shell initialization failures.
- Implements a focus event handler to prevent focus-out warnings.
- Introduces a launcher script to activate the virtual environment, force native Wayland, and preload the GTK4 Layer Shell library.
- Warns users of incorrect GDK_BACKEND settings.
- Updates the Ollama client to handle responses from both older and newer versions of the Ollama SDK.

These changes improve the application's stability, compatibility, and functionality on Wayland systems.
This commit is contained in:
Melvin Ragusa
2025-10-25 21:23:32 +02:00
parent da57c43e69
commit 1a80358ffc
10 changed files with 638 additions and 8 deletions

19
run.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Launcher script for Niri AI Sidebar with proper Wayland configuration
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# Activate virtual environment if it exists
if [ -f "$SCRIPT_DIR/.venv/bin/activate" ]; then
source "$SCRIPT_DIR/.venv/bin/activate"
fi
# Force GTK to use native Wayland backend (not XWayland)
export GDK_BACKEND=wayland
# Preload GTK4 Layer Shell library to ensure proper initialization
export LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so
# Run the application
exec python3 "$SCRIPT_DIR/main.py" "$@"