feat(macos): Relaunch app to fix tray icon and add Dock icon

This change modifies the macOS app bundle creation script to improve the application's behavior and user experience on macOS.

Previously, when Solaar was launched as a standard `.app` bundle, macOS restrictions sometimes prevented the GTK tray icon from appearing correctly. This change introduces a workaround in the wrapper script. The application now relaunches itself as a detached background process on the first launch. This new, detached process is no longer subject to the same `.app` bundle restrictions, allowing the tray icon to be created reliably.

Additionally, the `LSUIElement` key in the `Info.plist` is set to `false`. This makes Solaar a regular application with an icon in the Dock, which is the standard behavior expected by most macOS users for a graphical application.
This commit is contained in:
Din Tort 2025-10-27 21:19:54 +01:00
parent 436639ea91
commit dcdf159463
1 changed files with 16 additions and 1 deletions

View File

@ -31,7 +31,20 @@ WRAPPER="${MACOS_DIR}/solaar-wrapper"
cat > "${WRAPPER}" <<EOF
#!/usr/bin/env bash
set -euo pipefail
exec "${SOLAAR_RESOLVED_PATH}" "\$@"
# When launched via 'Solaar.app', macOS applies .app bundle restrictions
# that may prevent GTK from creating a tray icon properly.
# Workaround: Launch solaar in a detached background process
if [[ "\${SOLAAR_RELAUNCHED:-}" != "1" ]]; then
# First invocation from .app bundle - relaunch detached
export SOLAAR_RELAUNCHED=1
nohup "\$0" "\$@" >/dev/null 2>&1 &
exit 0
fi
# Second invocation - now detached, exec solaar normally
exec "${SOLAAR_RESOLVED_PATH}" "\$@"
EOF
chmod +x "${WRAPPER}"
@ -78,6 +91,8 @@ cat <<EOF
<string>11.0</string>
<key>NSInputMonitoringUsageDescription</key>
<string>Solaar needs to access input devices to configure and monitor your Logitech keyboards, mice, and other peripherals.</string>
<key>LSUIElement</key>
<false/>
EOF
if [[ ${HAVE_ICON} -eq 1 ]]; then
cat <<'EOF'