0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2025-04-01 23:03:44 +03:00

Merge pull request #162 from ein-shved/nix-tray-always

This commit is contained in:
Andrey Onischenko 2025-03-10 00:44:14 +03:00 committed by GitHub
commit 154458c1e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 46 additions and 4 deletions

View File

@ -12,10 +12,18 @@
, ymExe ? null
, electronArguments ? ""
, trayEnabled ? false
, trayStyle ? 1
, trayAlways ? false
, devTools ? false
, vibeAnimationMaxFps ? 25
, customTitleBar ? false
}:
let
inherit (lib) optionalString assertMsg;
version_info = with builtins; fromJSON (readFile ../utility/version_info.json);
in
assert assertMsg (trayStyle >= 1 && trayStyle <= 3) "Tray style must be withing 1 and 3";
assert assertMsg (vibeAnimationMaxFps >= 0) "Vibe animation max FPS must be greater then 0";
stdenvNoCC.mkDerivation
{
name = "yandex-music";
@ -53,14 +61,25 @@ stdenvNoCC.mkDerivation
'';
dontPatch = true;
config =''
ELECTRON_ARGS="${electronArguments}"
VIBE_ANIMATION_MAX_FPS=${toString vibeAnimationMaxFps}
'' + optionalString trayEnabled ''
TRAY_ENABLED=${toString trayStyle}
'' + optionalString trayAlways ''
ALWAYS_LEAVE_TO_TRAY=1
'' + optionalString devTools ''
DEV_TOOLS=1
'' + optionalString customTitleBar ''
CUSTOM_TITLE_BAR=1
'';
installPhase = ''
mkdir -p "$out/share/nodejs"
mv app/yandex-music.asar "$out/share/nodejs"
CONFIG_FILE="$out/share/yandex-music.conf"
echo "TRAY_ENABLED=${if trayEnabled then "1" else "0"}" >> "$CONFIG_FILE"
echo "ELECTRON_ARGS=\"${electronArguments}\"" >> "$CONFIG_FILE"
echo "$config" >> "$CONFIG_FILE"
install -Dm755 "$ymScript" "$out/bin/yandex-music"
sed -i "s|%electron_path%|${electron}/bin/electron|g" "$out/bin/yandex-music"

View File

@ -19,6 +19,24 @@ in
programs.yandex-music = {
enable = lib.mkEnableOption "yandex music application";
tray.enable = lib.mkEnableOption "tray icon for yandex music application";
tray.style = lib.mkOption {
description = "Style of tray icon. 1 is default, 2 is mono black, 3 is mono white";
default = 1;
type = lib.types.ints.between 1 3;
};
tray.always = lib.mkEnableOption "leave in tray disregarding of play state";
devTools.enable = lib.mkEnableOption "development tools";
vibeAnimationMaxFps = lib.mkOption {
description = ''
Vibe animation FPS from 0 (black screen) to to any reasonable number.
Recommended `25` - `144`
'';
default = 25;
type = lib.types.ints.unsigned;
};
customTitleBar.enable = lib.mkEnableOption ''
Yandex Music's custom Windows-styled titlebar
'';
electronArguments = lib.mkOption {
description = "Extra electron arguments";
example = "--no-sandbox --trace-warnings";
@ -30,7 +48,12 @@ in
type = lib.types.package;
default = pkgs.yandex-music.override {
trayEnabled = cfg.tray.enable;
electronArguments = cfg.electronArguments;
trayStyle = cfg.tray.style;
trayAlways = cfg.tray.always;
devTools = cfg.devTools.enable;
customTitleBar = cfg.customTitleBar.enable;
inherit (cfg) electronArguments vibeAnimationMaxFps;
};
};
};