diff --git a/pkgs/tools/games/scarab/default.nix b/pkgs/tools/games/scarab/default.nix index 617f8f0e87b27e..1709ce3048e19c 100644 --- a/pkgs/tools/games/scarab/default.nix +++ b/pkgs/tools/games/scarab/default.nix @@ -2,12 +2,15 @@ lib, buildDotnetModule, fetchFromGitHub, + bc, + glib, glibc, zlib, gtk3, copyDesktopItems, icoutils, wrapGAppsHook3, + writeText, makeDesktopItem, }: @@ -34,6 +37,8 @@ buildDotnetModule rec { ''; runtimeDeps = [ + bc + glib glibc zlib gtk3 @@ -60,6 +65,8 @@ buildDotnetModule rec { size=''${sizes[$i]}x''${sizes[$i]} install -D omegamaggotprime_''$((i+1))_''${size}x32.png $out/share/icons/hicolor/$size/apps/scarab.png done + + wrapProgram "$out/bin/Scarab" --run '. ${./scaling-settings.bash}' ''; desktopItems = [ diff --git a/pkgs/tools/games/scarab/scaling-settings.bash b/pkgs/tools/games/scarab/scaling-settings.bash new file mode 100644 index 00000000000000..109c2bdc5519af --- /dev/null +++ b/pkgs/tools/games/scarab/scaling-settings.bash @@ -0,0 +1,17 @@ +# Keep existing value if it is already non-empty +if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then + # Attempt to get GNOME desktop interface scaling factor + AVALONIA_GLOBAL_SCALE_FACTOR="$(gsettings get org.gnome.desktop.interface scaling-factor | cut --delimiter=' ' --fields=2)" +fi + +if [[ -z "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then + # Attempt to get scaling factor from X FreeType DPI setting + dpi="$(xrdb -get Xft.dpi)" + if [[ -n "$dpi" ]]; then + AVALONIA_GLOBAL_SCALE_FACTOR=$(echo "scale=2; $dpi/96" | bc) + fi +fi + +if [[ -n "${AVALONIA_GLOBAL_SCALE_FACTOR-}" ]]; then + export AVALONIA_GLOBAL_SCALE_FACTOR +fi