mirror of
				https://github.com/cucumber-sp/yandex-music-linux.git
				synced 2025-11-04 05:31:22 +03:00 
			
		
		
		
	Merge pull request #157 from alldevic/close-no-play
This commit is contained in:
		@@ -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`.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										28
									
								
								patches/0006-Always_leave_to_tray.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								patches/0006-Always_leave_to_tray.patch
									
									
									
									
									
										Normal file
									
								
							@@ -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();
 | 
			
		||||
         }
 | 
			
		||||
@@ -3,3 +3,4 @@ ELECTRON_ARGS="--no-sandbox"
 | 
			
		||||
TRAY_ENABLED=0
 | 
			
		||||
DEV_TOOLS=0
 | 
			
		||||
VIBE_ANIMATION_MAX_FPS=25
 | 
			
		||||
ALWAYS_LEAVE_TO_TRAY=0
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user