play.nix/lib/defualt.nix
2025-06-30 01:05:20 -04:00

53 lines
1.3 KiB
Nix

{ lib }:
{
# Helper to convert Nix attrs to gamescope command-line arguments
toCliArgs =
attrs:
let
argToString =
name: value:
if builtins.isBool value then
lib.optionalString value "--${name}"
else
"--${name} ${toString value}";
in
lib.concatStringsSep " " (lib.mapAttrsToList argToString attrs);
# Helper to convert Nix attrs to fish 'set -x' commands
toEnvCommands =
attrs:
lib.concatStringsSep "\n" (
lib.mapAttrsToList (name: value: "set -x ${name} '${toString value}'") attrs
);
getPrimaryMonitor = monitors: lib.findFirst (m: m.primary) null monitors;
getMonitorDefaults = monitors: {
WIDTH =
let
pm = lib.play.getPrimaryMonitor monitors;
in
if pm != null then pm.width else 1920;
HEIGHT =
let
pm = lib.play.getPrimaryMonitor monitors;
in
if pm != null then pm.height else 1080;
REFRESH_RATE =
let
pm = lib.play.getPrimaryMonitor monitors;
in
if pm != null then pm.refreshRate else 60;
VRR =
let
pm = lib.play.getPrimaryMonitor monitors;
in
if pm != null then pm.vrr else false;
HDR =
let
pm = lib.play.getPrimaryMonitor monitors;
in
if pm != null then pm.hdr else false;
};
}