0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2025-04-06 09:13:43 +03:00

Add icons

This commit is contained in:
Nikolay Bely 2025-02-07 10:53:39 +07:00
parent 7e5fcb0d2d
commit 8bb5e79f2a
11 changed files with 121 additions and 8 deletions

View File

@ -26,9 +26,10 @@ 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"
install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/YandexMusic.desktop"
install -Dm644 "$srcdir/yandex-music-linux/templates/default.conf" "$pkgdir/usr/lib/yandex-music/default.conf"

View File

@ -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)

View File

@ -33,9 +33,10 @@ 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"
install -Dm644 "./templates/desktop" "${app_dir}/usr/share/applications/YandexMusic.desktop"
install -Dm644 "./templates/default.conf" "${app_dir}/usr/lib/yandex-music/default.conf"
install -Dm644 "./LICENSE.md" "${app_dir}/usr/share/licenses/yandex-music/LICENSE"
mv "${TEMPDIR}/electron-${arch}/" "${app_dir}/usr/lib/yandex-music/electron"

BIN
icons/favicon-512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
icons/favicon-dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/favicon-light.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -71,9 +71,10 @@ 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"
install -Dm644 "$desktopItem" "$out/share/applications/YandexMusic.desktop"
'';
meta = {

View File

@ -0,0 +1,107 @@
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);
};

View File

@ -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"

View File

@ -26,9 +26,10 @@ 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"
install -Dm644 "$srcdir/yandex-music-linux/templates/desktop" "$pkgdir/usr/share/applications/YandexMusic.desktop"
install -Dm644 "$srcdir/yandex-music-linux/templates/default.conf" "$pkgdir/usr/lib/yandex-music/default.conf"

View File

@ -26,8 +26,9 @@ chmod 755 %{buildroot}/usr/bin/yandex-music
%files
/usr/bin/yandex-music
/usr/lib/yandex-music
/usr/share/applications/yandex-music.desktop
/usr/share/applications/YandexMusic.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