From a75f59cd800e05f682d5b721f016c63e87deba94 Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Tue, 30 Jan 2024 21:32:35 +0300 Subject: [PATCH] Add do not fix quit flag Electron is quite unoptimised technology and running YM window in foreground requires a lot of cpu usage. So hiding window to background is more feature, then bug =) Change-Id: Id4e00303379004b6353a88efd7232e180f80fe6d --- flake.nix | 3 +++ nix/default.nix | 3 ++- repack.sh | 14 ++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 3368976..24f4a8a 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,9 @@ { packages = rec { yandex-music = yandex-music-with pkgs; + yandex-music-backgroud = yandex-music.override { + fixQuit = false; + }; default = yandex-music; }; } diff --git a/nix/default.nix b/nix/default.nix index aa9927d..47b1a5d 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -10,6 +10,7 @@ , jq , ymExe +, fixQuit ? true }: let app = runCommand "yandex-music-app" @@ -18,7 +19,7 @@ let repack = ./../repack.sh; src = ymExe; } '' - bash "$repack" -o "$out" "$src" + bash "$repack" ${if !fixQuit then "-q" else ""} -o "$out" "$src" ''; launcher = writeShellApplication { name = "yandex-music"; diff --git a/repack.sh b/repack.sh index eddff1b..16dd3b3 100755 --- a/repack.sh +++ b/repack.sh @@ -3,20 +3,23 @@ set -e usage() { - echo "Usage: $(basename "$0") [-xh] [ -o DIR] YANDEX_MUSIC_EXE" + echo "Usage: $(basename "$0") [-xqh] [ -o DIR] YANDEX_MUSIC_EXE" echo echo " Options:" echo " -o DIR Path to destination folder" echo " -x Extract and fix only to destination folder" + echo " -q Do not apply application quit fix" echo " -h Show this help and exit" } exe_location= dst="$PWD/app" -while getopts :xo:h name; do +fix_quit=1 +while getopts :xo:qh name; do case $name in x) extract_only=1 ;; o) dst="$OPTARG" ;; + q) fix_quit=0 ;; h) usage exit 0 @@ -79,8 +82,11 @@ find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do done echo "Title Fixed" -echo "Fixing App Quiting" -sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" "./main/lib/handlers/handleWindowLifecycleEvents.js" +if [ "$fix_quit" == "1" ]; then + echo "Fixing App Quiting" + sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" \ + "./main/lib/handlers/handleWindowLifecycleEvents.js" +fi if ! command -v jq &>/dev/null; then echo "Error: jq is not installed. Please install jq to proceed." >&2