diff --git a/patches/0003-Create-app-tray-icon.patch b/patches/0003-Create-app-tray-icon.patch index 7584be1..42a748e 100644 --- a/patches/0003-Create-app-tray-icon.patch +++ b/patches/0003-Create-app-tray-icon.patch @@ -1,13 +1,15 @@ diff --git a/main/lib/preload.js b/main/lib/preload.js --- a/main/lib/preload.js +++ b/main/lib/preload.js -@@ -11,2 +11,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); +@@ -11,2 +11,4 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); const customTitleBar = process.env.CUSTOM_TITLE_BAR && process.env.CUSTOM_TITLE_BAR > 0; +const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0; ++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)); -@@ -17,2 +17,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); +@@ -17,2 +19,4 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); electron_1.contextBridge.exposeInMainWorld('CUSTOM_TITLE_BAR', customTitleBar); +electron_1.contextBridge.exposeInMainWorld('IS_TRAY_ENABLED', trayEnabled); ++electron_1.contextBridge.exposeInMainWorld('ALWAYS_LEAVE_TO_TRAY', alwaysLeaveToTray); electron_1.contextBridge.exposeInMainWorld('desktopEvents', { @@ -27,23 +29,27 @@ diff --git a/main/index.js b/main/index.js 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 -@@ -24,2 +24,4 @@ +@@ -24,2 +24,5 @@ const handleWindowLifecycleEvents = (window) => { + const isPlatformWindows = deviceInfo_js_1.devicePlatform === platform_js_1.Platform.WINDOWS; + 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', () => { -@@ -31,5 +33,5 @@ const handleWindowLifecycleEvents = (window) => { +@@ -31,5 +34,5 @@ const handleWindowLifecycleEvents = (window) => { electron_1.app.on('window-all-closed', () => { - if ([platform_js_1.Platform.WINDOWS, platform_js_1.Platform.LINUX].includes(deviceInfo_js_1.devicePlatform)) { + if (!isTrayEnabled || isPlatformWindows) { electron_1.app.quit(); } }); -@@ -54,18 +56,10 @@ const handleWindowLifecycleEvents = (window) => { +@@ -54,18 +57,13 @@ const handleWindowLifecycleEvents = (window) => { window.on('close', (event) => { - if (deviceInfo_js_1.devicePlatform !== platform_js_1.Platform.MACOS) { - return; - } ++ if (isTrayEnabled && !isAlwaysLeaveToTray && !state_js_1.state.player.isPlaying) { ++ electron_1.app.quit(); ++ } + if (!isTrayEnabled) { + electron_1.app.quit(); + } @@ -113,3 +119,19 @@ diff --git a/package.json b/package.json @@ -3,1 +3,1 @@ - "name": "YandexMusic", + "name": "yandex-music", + + +diff --git a/main/events.js b/main/events.js +--- a/main/events.js ++++ b/main/events.js +@@ -38,8 +38,8 @@ const handleApplicationEvents = (window) => { + }); + electron_1.ipcMain.on(events_js_1.Events.WINDOW_CLOSE, () => { + eventsLogger.info('Event received', events_js_1.Events.WINDOW_CLOSE); +- if (platform_js_1.Platform.WINDOWS === deviceInfo_js_1.devicePlatform) { +- if (state_js_1.state.player.isPlaying) { ++ if (process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0) { ++ if ((process.env.ALWAYS_LEAVE_TO_TRAY && process.env.ALWAYS_LEAVE_TO_TRAY > 0) || state_js_1.state.player.isPlaying) { + (0, createWindow_js_1.toggleWindowVisibility)(window, false); + } + else { diff --git a/patches/0004-Vibe-animation-max-FPS.patch b/patches/0004-Vibe-animation-max-FPS.patch index 532f65b..fdf41d2 100644 --- a/patches/0004-Vibe-animation-max-FPS.patch +++ b/patches/0004-Vibe-animation-max-FPS.patch @@ -1,11 +1,11 @@ diff --git a/main/lib/preload.js b/main/lib/preload.js --- a/main/lib/preload.js +++ b/main/lib/preload.js -@@ -12,2 +12,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); - const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0; +@@ -13,2 +13,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); + const alwaysLeaveToTray = process.env.ALWAYS_LEAVE_TO_TRAY && process.env.ALWAYS_LEAVE_TO_TRAY > 0; +const vibeAnimationMaxFps = process.env.VIBE_ANIMATION_MAX_FPS ?? 25; electron_1.contextBridge.exposeInMainWorld('VERSION', String(config_js_1.config.buildInfo.VERSION)); -@@ -19,2 +20,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); - electron_1.contextBridge.exposeInMainWorld('IS_TRAY_ENABLED', trayEnabled); +@@ -21,2 +22,3 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); + electron_1.contextBridge.exposeInMainWorld('ALWAYS_LEAVE_TO_TRAY', alwaysLeaveToTray); +electron_1.contextBridge.exposeInMainWorld('VIBE_ANIMATION_MAX_FPS', vibeAnimationMaxFps); electron_1.contextBridge.exposeInMainWorld('desktopEvents', { diff --git a/patches/0006-Always_leave_to_tray.patch b/patches/0006-Always_leave_to_tray.patch deleted file mode 100644 index 3f0385d..0000000 --- a/patches/0006-Always_leave_to_tray.patch +++ /dev/null @@ -1,28 +0,0 @@ -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 5f335f9..c259f50 100644 --- a/templates/default.conf +++ b/templates/default.conf @@ -1,6 +1,7 @@ ELECTRON_CUSTOM_BIN= ELECTRON_ARGS="--no-sandbox" TRAY_ENABLED=0 -DEV_TOOLS=0 -VIBE_ANIMATION_MAX_FPS=25 ALWAYS_LEAVE_TO_TRAY=0 +DEV_TOOLS=0 +CUSTOM_TITLE_BAR=0 +VIBE_ANIMATION_MAX_FPS=25 diff --git a/templates/yandex-music.sh b/templates/yandex-music.sh index fcb4e21..8e59223 100644 --- a/templates/yandex-music.sh +++ b/templates/yandex-music.sh @@ -23,9 +23,9 @@ fi ELECTRON_BIN=${ELECTRON_CUSTOM_BIN:-%electron_path%} export TRAY_ENABLED=${TRAY_ENABLED:-0} +export ALWAYS_LEAVE_TO_TRAY=${ALWAYS_LEAVE_TO_TRAY:-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