Jovian-Experiments / Jovian-NixOS

Discussions: https://matrix.to/#/#Jovian-Experiments:matrix.org
https://jovian-experiments.github.io/Jovian-NixOS/
MIT License
531 stars 53 forks source link

Add options for gamescope #5

Open samueldr opened 2 years ago

samueldr commented 2 years ago

Add options for gamescope+steam

Relevant options:

  -w, --nested-width             game width
  -h, --nested-height            game height
  -r, --nested-refresh           game refresh rate (frames per second)
  -m, --max-scale                maximum scale factor
  -i, --integer-scale            force scale factor to integer
  -W, --output-width             output width
  -H, --output-height            output height
  -n, --nearest-neighbor-filter  use nearest neighbor filtering
  -U  --fsr-upscaling            use AMD FidelityFX™ Super Resolution 1.0 for upscaling
  --fsr-sharpness                FSR sharpness from 0 (max) to 20 (min)
  --cursor                       path to default cursor image
  -C, --hide-cursor-delay        hide cursor image after delay
  -e, --steam                    enable Steam integration
 --xwayland-count                create N xwayland servers

Nested mode options:
  -o, --nested-unfocused-refresh game refresh rate when unfocused
  -b, --borderless               make the window borderless
  -f, --fullscreen               make the window fullscreen

Embedded mode options:
  -O, --prefer-output            list of connectors in order of preference

_Originally posted by @samueldr in https://github.com/Jovian-Experiments/Jovian-NixOS/pull/3#discussion_r851590072_

m1cr0man commented 1 year ago

Giving this a shot.

m1cr0man commented 1 year ago

It's been a hot minute.. but finally got around to working on this again and nearly had it finished, and then subsequently realized that the custom gamescope-session was removed.

I have hand mapped each arg shown in gamescope --help to an equivalent module option. For defaults, I've used either the value defined in gamescope_incantation or the current gamescope default - in that order of precedence.

Since we don't need this any more, I'm just going to leave this comparison of the branches here, and possibly close this ticket. https://github.com/Jovian-Experiments/Jovian-NixOS/compare/development...m1cr0man:Jovian-NixOS:081eb3354d2ffdefa8c98bed352dc8727cd0c328?expand=1

deftdawg commented 4 months ago

I clicked on your link and thinking it was merged just tried the following... then realized it was from your repo, dough!
You say we don't need this anymore, but I couldn't figure out the correct way to reorder the prefered outputs looking at the Jovian docs

  jovian.steam = {
    enable = true;
    autoStart = true;
    desktopSession = "plasma";
    gamescopeOptions = {
      preferOutput = [ "DP-*" "HDMI-*" "*" "eDP-1" ];
    };
  };
m1cr0man commented 4 months ago

My statement on not needing this was related to the fact that the custom gamescope-session was removed and so all the custom options wouldn't actually have any effect anymore.

Nowadays, you would have to add a patch to pkgs.gamescope-session and modify the preferOutput line. Fortunately, I imagine that line is pretty stable and a patch should survive multiple updates. Unfortunately, it is a bit more awkward than if there was options implemented.

m1cr0man commented 4 months ago

Come to think of it, perhaps there is a path forward...

We could add a patch converting most of the gamescope invokation arguments to an environment variable, and use a systemd override defined in the Nix config for a system to specify the gamescopeOptions to use through said env var. It means we don't need a custom copy of the entirety of gamescope-session, and provide the flexibility that the option set grants. The option defaults would have to match the vendor defaults, resulting in the same args. Example POC:

{ config, ... }: {
  systemd.services.gamescope-session = {
    overrideStrategy = "asDropin";
    environment.GAMESCOPE_ARGS = config.jovian.steam.gamescopeOptions.finalArguments;
  }; 
} 

.. and would also need the relevant gamescope-session patch. Happy to do a PR if there's interest, but I don't actually run NixOS on my own deck anymore so I can't test it :sweat_smile: