diff --git a/PKGBUILD b/PKGBUILD index 714f02d..e1ad10d 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -26,6 +26,7 @@ package() { install -Dm644 "$srcdir/app/favicon.png" "$pkgdir/usr/share/pixmaps/yandex-music.png" install -Dm644 "$srcdir/app/favicon.png" "$pkgdir/usr/share/icons/hicolor/48x48/apps/yandex-music.png" + install -Dm644 "$srcdir/app/favicon-512x512.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/yandex-music.png" install -Dm644 "$srcdir/app/favicon.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/yandex-music.desktop" diff --git a/README.md b/README.md index 7f0df2c..ce0e2b6 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,7 @@ ELECTRON_ARGS="--no-sandbox --trace-warnings" ### Tray mode -Tray mode is disabled by default. It allows program to be minimized to tray instead of closing. To enable it set `TRAY_ENABLED` option to `1`. - -Temporary unavailable from v5.30.3 +Tray mode is disabled by default. It allows program to be minimized to tray instead of closing. To enable it set `TRAY_ENABLED` option to `1`, `2` - mono black icon, `3` - mono white. ![image](https://github.com/cucumber-sp/yandex-music-linux/assets/100789522/5998ba7f-9ee7-4725-9d51-fbe5510a799d) diff --git a/build_tarball.sh b/build_tarball.sh index f9be65e..dc34f80 100644 --- a/build_tarball.sh +++ b/build_tarball.sh @@ -33,6 +33,7 @@ build_tarball(){ install -Dm644 "${TEMPDIR}/app/favicon.png" "${app_dir}/usr/share/pixmaps/yandex-music.png" install -Dm644 "${TEMPDIR}/app/favicon.png" "${app_dir}/usr/share/icons/hicolor/48x48/apps/yandex-music.png" + install -Dm644 "${TEMPDIR}/app/favicon-512x512.png" "${app_dir}/usr/share/icons/hicolor/512x512/apps/yandex-music.png" install -Dm644 "${TEMPDIR}/app/favicon.svg" "${app_dir}/usr/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "./templates/desktop" "${app_dir}/usr/share/applications/yandex-music.desktop" diff --git a/icons/favicon-512x512.png b/icons/favicon-512x512.png new file mode 100644 index 0000000..fffd079 Binary files /dev/null and b/icons/favicon-512x512.png differ diff --git a/icons/favicon-dark.png b/icons/favicon-dark.png new file mode 100644 index 0000000..6aaf042 Binary files /dev/null and b/icons/favicon-dark.png differ diff --git a/icons/favicon-light.png b/icons/favicon-light.png new file mode 100644 index 0000000..1070e9d Binary files /dev/null and b/icons/favicon-light.png differ diff --git a/nix/default.nix b/nix/default.nix index 35363f9..89b0f91 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -71,6 +71,7 @@ stdenvNoCC.mkDerivation install -Dm644 "./app/favicon.png" "$out/share/pixmaps/yandex-music.png" install -Dm644 "./app/favicon.png" "$out/share/icons/hicolor/48x48/apps/yandex-music.png" + install -Dm644 "./app/favicon-512x512.png" "$out/usr/share/icons/hicolor/512x512/apps/yandex-music.png" install -Dm644 "./app/favicon.svg" "$out/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "$desktopItem" "$out/share/applications/yandex-music.desktop" diff --git a/patches/0001-Dev-Tools-from-config.patch b/patches/0001-Dev-Tools-from-config.patch index dc1039c..7c996d8 100644 --- a/patches/0001-Dev-Tools-from-config.patch +++ b/patches/0001-Dev-Tools-from-config.patch @@ -13,3 +13,17 @@ diff --git a/main/config.js b/main/config.js enableWebSecurity: true, enableAutoUpdate: true, enableUpdateByProbability: true, + + +diff --git a/main/lib/preload.js b/main/lib/preload.js +--- a/main/lib/preload.js ++++ b/main/lib/preload.js +@@ -9,6 +9,8 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); + const deviceInfo = (0, deviceInfo_js_1.getDeviceInfo)(); ++const devTools = process.env.DEV_TOOLS && process.env.DEV_TOOLS > 0; + electron_1.contextBridge.exposeInMainWorld('VERSION', String(config_js_1.config.buildInfo.VERSION)); + electron_1.contextBridge.exposeInMainWorld('BRANCH', String(config_js_1.config.buildInfo.BRANCH)); + electron_1.contextBridge.exposeInMainWorld('PLATFORM', deviceInfo.os); + electron_1.contextBridge.exposeInMainWorld('DEVICE_INFO', deviceInfo); ++electron_1.contextBridge.exposeInMainWorld('IS_DEVTOOLS_ENABLED', devTools); + electron_1.contextBridge.exposeInMainWorld('desktopEvents', { diff --git a/patches/0002-Custom-title-bar-and-Dev-Tools-expose.patch b/patches/0002-Custom-title-bar.patch similarity index 72% rename from patches/0002-Custom-title-bar-and-Dev-Tools-expose.patch rename to patches/0002-Custom-title-bar.patch index c6e1e07..f11eb48 100644 --- a/patches/0002-Custom-title-bar-and-Dev-Tools-expose.patch +++ b/patches/0002-Custom-title-bar.patch @@ -20,7 +20,7 @@ diff --git a/main/index.js b/main/index.js diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js --- a/main/lib/createWindow.js +++ b/main/lib/createWindow.js -@@ -38,13 +38,13 @@ const toggleWindowState = (window) => { +@@ -38,13 +38,14 @@ const toggleWindowState = (window) => { (0, tray_js_1.updateTrayMenu)(window); }; exports.toggleWindowState = toggleWindowState; @@ -33,27 +33,20 @@ diff --git a/main/lib/createWindow.js b/main/lib/createWindow.js center: true, frame: withFrame, - titleBarStyle: 'hidden', ++ ...(customTitleBar ? { titleBarStyle: 'hidden'} : {}), trafficLightPosition: { x: 16, y: 10 - diff --git a/main/lib/preload.js b/main/lib/preload.js --- a/main/lib/preload.js +++ b/main/lib/preload.js -@@ -7,10 +7,14 @@ const deviceInfo_js_1 = require("./deviceInfo.js"); - const theme_js_1 = require("../types/theme.js"); - const hostnamePatterns_js_1 = require("../constants/hostnamePatterns.js"); - const deviceInfo = (0, deviceInfo_js_1.getDeviceInfo)(); +@@ -10,2 +10,3 @@ + const devTools = process.env.DEV_TOOLS && process.env.DEV_TOOLS > 0; +const customTitleBar = process.env.CUSTOM_TITLE_BAR && process.env.CUSTOM_TITLE_BAR > 0; -+const devTools = process.env.DEV_TOOLS && process.env.DEV_TOOLS > 0; electron_1.contextBridge.exposeInMainWorld('VERSION', String(config_js_1.config.buildInfo.VERSION)); - electron_1.contextBridge.exposeInMainWorld('BRANCH', String(config_js_1.config.buildInfo.BRANCH)); - electron_1.contextBridge.exposeInMainWorld('PLATFORM', deviceInfo.os); - electron_1.contextBridge.exposeInMainWorld('DEVICE_INFO', deviceInfo); +@@ -15,2 +16,3 @@ + electron_1.contextBridge.exposeInMainWorld('IS_DEVTOOLS_ENABLED', devTools); +electron_1.contextBridge.exposeInMainWorld('CUSTOM_TITLE_BAR', customTitleBar); -+electron_1.contextBridge.exposeInMainWorld('IS_DEVTOOLS_ENABLED', devTools); electron_1.contextBridge.exposeInMainWorld('desktopEvents', { - send(name, ...args) { - electron_1.ipcRenderer.send(name, ...args); diff --git a/patches/0003-Create-app-tray-icon.patch b/patches/0003-Create-app-tray-icon.patch new file mode 100644 index 0000000..74c7400 --- /dev/null +++ b/patches/0003-Create-app-tray-icon.patch @@ -0,0 +1,117 @@ +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"); + const customTitleBar = process.env.CUSTOM_TITLE_BAR && process.env.CUSTOM_TITLE_BAR > 0; ++const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0; + electron_1.contextBridge.exposeInMainWorld('VERSION', String(config_js_1.config.buildInfo.VERSION)); +@@ -17,2 +17,3 @@ 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('desktopEvents', { + + +diff --git a/main/index.js b/main/index.js +--- a/main/index.js ++++ b/main/index.js +@@ -34,4 +34,6 @@ Logger_js_1.Logger.setupLogger(); + const window = await (0, createWindow_js_1.createWindow)(); ++ const isPlatformWindows = deviceInfo_js_1.devicePlatform === platform_js_1.Platform.WINDOWS; ++ const trayEnabled = process.env.TRAY_ENABLED && process.env.TRAY_ENABLED > 0; +- if (deviceInfo_js_1.devicePlatform === platform_js_1.Platform.WINDOWS) { ++ if (trayEnabled || isPlatformWindows) { + (0, tray_js_1.setupTray)(window); + } + + +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 @@ + 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; + electron_1.app.on('activate', () => { +@@ -31,5 +33,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) => { + window.on('close', (event) => { +- if (deviceInfo_js_1.devicePlatform !== platform_js_1.Platform.MACOS) { +- return; +- } ++ if (!isTrayEnabled) { ++ electron_1.app.quit(); ++ } + if (state_js_1.state.willQuit) { + return; + } + event.preventDefault(); +- if (window.isFullScreen()) { +- window.once('leave-full-screen', () => { +- (0, createWindow_js_1.toggleWindowVisibility)(window, false); +- }); +- window.setFullScreen(false); +- } +- else { +- (0, createWindow_js_1.toggleWindowVisibility)(window, false); +- } ++ (0, createWindow_js_1.toggleWindowVisibility)(window, false); + }); + + +diff --git a/main/lib/tray.js b/main/lib/tray.js +--- a/main/lib/tray.js ++++ b/main/lib/tray.js +@@ -5,3 +5,2 @@ + const node_path_1 = require("node:path"); +-const updater_js_1 = require("./updater.js"); + const i18n_js_1 = require("./i18n.js"); +@@ -14,4 +13,6 @@ + const trayIcon = () => { +- const iconPath = (0, node_path_1.join)(process.resourcesPath, 'assets', 'icon.ico'); ++ const isTrayEnabled = process.env.TRAY_ENABLED; ++ const iconFile = isTrayEnabled == 2 ? 'favicon-dark.png' : (isTrayEnabled == 3 ? `favicon-light.png` : 'favicon.png'); ++ const iconPath = (0, node_path_1.join)(__dirname, '../../app', iconFile); + return electron_1.nativeImage.createFromPath(iconPath); + }; +@@ -18,3 +20,2 @@ + const createContextMenu = (window) => { +- const updater = (0, updater_js_1.getUpdater)(); + const windowStateLabel = state_js_1.state.isWindowHidden || window.isMinimized() +@@ -32,8 +33,2 @@ const createContextMenu = (window) => { + }, +- { +- label: (0, i18n_js_1.formatMessage)({ id: 'desktop.check-for-updates' }), +- click() { +- updater.check(); +- } +- }, + { +@@ -83,8 +79,6 @@ const setupTray = (window) => { + (0, exports.updateTrayMenu)(window); +- tray.on('click', () => { +- (0, createWindow_js_1.toggleWindowState)(window); +- }); +- tray.on('double-click', () => { +- (0, createWindow_js_1.toggleWindowState)(window); +- }); ++ tray.on('click', () => { ++ window.show(); ++ }); ++ tray.setIgnoreDoubleClickEvents(true); + }; + + +diff --git a/package.json b/package.json +--- a/package.json ++++ b/package.json +@@ -2,3 +2,3 @@ { + "private": true, +- "name": "YandexMusic", ++ "name": "yandex-music", + "version": "5.37.1", diff --git a/repack.sh b/repack.sh index 9064faf..9252acd 100755 --- a/repack.sh +++ b/repack.sh @@ -134,5 +134,8 @@ asar pack "$TEMPDIR/app" "$dst/yandex-music.asar" for ext in png svg; do mv "$TEMPDIR/app/app/favicon.$ext" "$dst" done +mv "$TEMPDIR/app/app/favicon-512x512.png" "$dst" +mv "$TEMPDIR/app/app/favicon-dark.png" "$dst" +mv "$TEMPDIR/app/app/favicon-light.png" "$dst" echo "Done" diff --git a/templates/PKGBUILD b/templates/PKGBUILD index 09a7a11..efa8ab1 100644 --- a/templates/PKGBUILD +++ b/templates/PKGBUILD @@ -26,6 +26,7 @@ package() { install -Dm644 "$srcdir/app/favicon.png" "$pkgdir/usr/share/pixmaps/yandex-music.png" install -Dm644 "$srcdir/app/favicon.png" "$pkgdir/usr/share/icons/hicolor/48x48/apps/yandex-music.png" + install -Dm644 "$srcdir/app/favicon-512x512.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/yandex-music.png" install -Dm644 "$srcdir/app/favicon.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/yandex-music.svg" install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/yandex-music.desktop" diff --git a/templates/desktop b/templates/desktop index aefda5f..6857881 100644 --- a/templates/desktop +++ b/templates/desktop @@ -3,11 +3,11 @@ Name=Yandex Music Name[ru]=Яндекс Музыка Comment=Yandex Music — we collect music for you Comment[ru]=Яндекс Музыка — собираем музыку для вас -GenericName=YandexMusic +GenericName=yandex-music Exec=yandex-music --no-sandbox %U Icon=yandex-music Type=Application StartupNotify=true -StartupWMClass=YandexMusic +StartupWMClass=yandex-music MimeType=x-scheme-handler/yandexmusic Categories=Audio;Music;Player;AudioVideo diff --git a/templates/rpm.spec b/templates/rpm.spec index d09bb93..463772f 100644 --- a/templates/rpm.spec +++ b/templates/rpm.spec @@ -28,6 +28,7 @@ chmod 755 %{buildroot}/usr/bin/yandex-music /usr/lib/yandex-music /usr/share/applications/yandex-music.desktop /usr/share/icons/hicolor/48x48/apps/yandex-music.png +/usr/share/icons/hicolor/512x512/apps/yandex-music.png /usr/share/icons/hicolor/scalable/apps/yandex-music.svg /usr/share/licenses/yandex-music /usr/share/pixmaps/yandex-music.png \ No newline at end of file