spotify: support --force-device-scale-factor

Add a Spotify wrapper with a `deviceScaleFactor` argument to set the
`--force-device-scale-factor` flag for high-DPI displays. If unset,
nothing is added.

This allows e.g.

   spotify.override { deviceScaleFactor = 1.66; }

Uses a separate wrapper derivation as suggested by @Ma27.
Uses `wrapProgram` instead of `makeWrapper` as suggested by @Ma27.
gstqt5
Rebecca Turner 2020-09-20 17:37:59 -04:00
parent 41e883a657
commit 4f03644c56
3 changed files with 35 additions and 2 deletions

View File

@ -64,7 +64,7 @@ let
in
stdenv.mkDerivation {
pname = "spotify";
pname = "spotify-unwrapped";
inherit version;
# fetch from snapcraft instead of the debian repository most repos fetch from.

View File

@ -0,0 +1,31 @@
{ symlinkJoin
, lib
, spotify-unwrapped
, makeWrapper
# High-DPI support: Spotify's --force-device-scale-factor argument; not added
# if `null`, otherwise, should be a number.
, deviceScaleFactor ? null
}:
symlinkJoin {
name = "spotify-${spotify-unwrapped.version}";
paths = [ spotify-unwrapped.out ];
nativeBuildInputs = [ makeWrapper ];
preferLocalBuild = true;
passthru.unwrapped = spotify-unwrapped;
postBuild = ''
wrapProgram $out/bin/spotify \
${lib.optionalString (deviceScaleFactor != null) ''
--add-flags ${lib.escapeShellArg "--force-device-scale-factor=${
builtins.toString deviceScaleFactor
}"}
''}
'';
meta = spotify-unwrapped.meta // {
priority = (spotify-unwrapped.meta.priority or 0) - 1;
};
}

View File

@ -23326,7 +23326,7 @@ in
spek = callPackage ../applications/audio/spek { };
spotify = callPackage ../applications/audio/spotify {
spotify-unwrapped = callPackage ../applications/audio/spotify {
libgcrypt = libgcrypt_1_5;
libpng = libpng12;
curl = curl.override {
@ -23334,6 +23334,8 @@ in
};
};
spotify = callPackage ../applications/audio/spotify/wrapper.nix { };
libspotify = callPackage ../development/libraries/libspotify (config.libspotify or {});
sourcetrail = callPackage ../development/tools/sourcetrail { };