diff --git a/README.md b/README.md index 736cf3e..4a1328b 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Native YandexMusic client for Linux. Built using repacking of Windows client (El - [Custom Electron binary](#custom-electron-binary) - [Electron arguments](#electron-arguments) - [Tray mode](#tray-mode) + - [Always leave to tray](#always-leave-to-tray) - [Dev tools](#dev-tools) - [Custom title bar](#custom-title-bar) - [Vibe animation FPS control](#vibe-animation-fps-control) @@ -150,6 +151,12 @@ Tray mode is disabled by default. It allows program to be minimized to tray inst *** +### Always leave to tray + +By default, if the TRAY_ENABLED option is enabled, then if the player is paused, the application will close instead of minimizing to the system tray. The `ALWAYS_LEAVE_TO_TRAY=1` option changes this behavior. + +*** + ### Dev tools Chromium developer/debug tools can be enabled by setting `DEV_TOOLS` option to `1`. diff --git a/patches/0006-Always_leave_to_tray.patch b/patches/0006-Always_leave_to_tray.patch new file mode 100644 index 0000000..3f0385d --- /dev/null +++ b/patches/0006-Always_leave_to_tray.patch @@ -0,0 +1,28 @@ +diff --git a/main/lib/preload.js b/main/lib/preload.js +--- a/main/lib/preload.js ++++ b/main/lib/preload.js +@@ -13,2 +13,3 @@ + const vibeAnimationMaxFps = process.env.VIBE_ANIMATION_MAX_FPS ?? 25; ++const alwaysLeaveToTray = process.env.ALWAYS_LEAVE_TO_TRAY && process.env.ALWAYS_LEAVE_TO_TRAY > 0; + electron_1.contextBridge.exposeInMainWorld('VERSION', String(config_js_1.config.buildInfo.VERSION)); +@@ -21,2 +22,3 @@ + electron_1.contextBridge.exposeInMainWorld('VIBE_ANIMATION_MAX_FPS', vibeAnimationMaxFps); ++electron_1.contextBridge.exposeInMainWorld('ALWAYS_LEAVE_TO_TRAY', alwaysLeaveToTray); + electron_1.contextBridge.exposeInMainWorld('desktopEvents', { + + +diff --git a/main/lib/handlers/handleWindowLifecycleEvents.js b/main/lib/handlers/handleWindowLifecycleEvents.js +--- a/main/lib/handlers/handleWindowLifecycleEvents.js ++++ b/main/lib/handlers/handleWindowLifecycleEvents.js +@@ -26,2 +26,3 @@ + const isTrayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0; ++ const isAlwaysLeaveToTray = process.env.ALWAYS_LEAVE_TO_TRAY && process.env.ALWAYS_LEAVE_TO_TRAY > 0; + electron_1.app.on('activate', () => { +@@ -56,4 +57,7 @@ const handleWindowLifecycleEvents = (window) => { + window.on('close', (event) => { ++ if (isTrayEnabled && !isAlwaysLeaveToTray && !state_js_1.state.player.isPlaying) { ++ electron_1.app.quit(); ++ } + if (!isTrayEnabled) { + electron_1.app.quit(); + } diff --git a/templates/default.conf b/templates/default.conf index 7dfe4bb..5f335f9 100644 --- a/templates/default.conf +++ b/templates/default.conf @@ -3,3 +3,4 @@ ELECTRON_ARGS="--no-sandbox" TRAY_ENABLED=0 DEV_TOOLS=0 VIBE_ANIMATION_MAX_FPS=25 +ALWAYS_LEAVE_TO_TRAY=0 diff --git a/templates/yandex-music.sh b/templates/yandex-music.sh index 33d26b0..fcb4e21 100644 --- a/templates/yandex-music.sh +++ b/templates/yandex-music.sh @@ -26,5 +26,6 @@ export TRAY_ENABLED=${TRAY_ENABLED:-0} export DEV_TOOLS=${DEV_TOOLS:-0} export CUSTOM_TITLE_BAR=${CUSTOM_TITLE_BAR:-0} export VIBE_ANIMATION_MAX_FPS=${VIBE_ANIMATION_MAX_FPS:-25} +export ALWAYS_LEAVE_TO_TRAY=${ALWAYS_LEAVE_TO_TRAY:-0} exec "${ELECTRON_BIN}" "%asar_path%" $ELECTRON_ARGS $WAYLAND_FLAGS