Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config file support #1344

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bertogg
Copy link

@bertogg bertogg commented May 30, 2024

Load config files from /etc/gamescope.d/*.conf in json format.

This currently allows the user to specify the allowed refresh rates for different displays.

Here's the first draft, feedback is welcome.

cc @lostgoat

Load config files from /etc/gamescope.d/*.conf in json format.

This currently allows the user to specify the allowed refresh rates
for different displays.
for (const auto& iter : std::filesystem::directory_iterator(config_dir))
{
const auto& path = iter.path();
if (std::filesystem::is_regular_file(iter.status()) && path.extension() == ".conf")
Copy link

@lostgoat lostgoat May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on the fence about using a .conf extensions here. Since the contents are json that makes me want to lean towards the extension being .json instead.

Overall, not a big deal, will go with whatever you or @Joshua-Ashton think is best

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually using .json initially 🙂 but I really don't mind, both options are fine with me.

}
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add an example_config.json to the install output? Sort of as a config documentation with every field commented out.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is installing it as config.json.sample so it would be ignored by default because of the extension (that's how scripts in .git/hooks work).

@bertogg
Copy link
Author

bertogg commented May 30, 2024

One more thing in case it matters: since the code to read the config dir is quite simple I can save a few KBs on the final binary by using standard libc calls instead of std::filesystem at the expense of slightly more verbose code.

@lostgoat
Copy link

Using std::filesystem should be fine. I don't think a few KBs are worth rolling our own.

@Conan-Kudo
Copy link

Should it be json formatted? also stuff only in /etc makes it difficult for things to ship default configs... maybe something like libeconf would help for being able to do layered in /usr and /etc?

@matte-schwartz
Copy link

matte-schwartz commented Jun 10, 2024

great to see movement on something like this! couple ideas as an avid gamescope and handheld PC user that I think might make sense to add as options:

  1. adding an easy way to scale the Steam UI for internal panels - perhaps in a simple flag like ui-scale-factor=2.00? this would be huge for handheld devices with higher resolution displays than the Steam Deck - such as the ROG Ally which is 1920x1080p or the even more egregious Legion Go which is 2560x1600p. as far as i'm aware, the only option to do this right now is either 1: make gamescope think your panel is external with a forked version of gamescope or 2: rely on third-party extensions to access "hidden" dev options that end users should definitely not be messing with

  2. adding in a way for users to define the default resolution that gamescope should use for games in an embedded context like gamescope-session, offering an easy way to bypass the 720p restriction within steam without having to go into every game entry and change Default -> Native (or whatever other resolution you'd prefer). this is probably a better option something like always defaulting to a monitor's native resolution in case people hook up 4K monitors or TVs to a Steam Deck so they're not left with 5fps in games unexpectedly.

both of these would go a long way towards improving the end user experience on handheld PCs and make it easier to ship upstream gamescope to a wider variety of devices.

and perhaps as a future suggestion - expanding this to support specifying a default audio output device for gamescope-session would be sweet. I've noticed that using the Valve provided gamescope-session can sometimes lead to the default output getting changed during session-switches to something like the internal speakers, rather than a preferred external audio playback device. accounting for that in here would give users a way to do this without messing directly with pipewire, which I think many casual linux users are unfamiliar with.

@lostgoat
Copy link

lostgoat commented Jun 10, 2024

great to see movement on something like this! couple ideas as an avid gamescope and handheld PC user that I think might make sense to add as options:

1. adding an easy way to scale the Steam UI for internal panels - perhaps in a simple flag like `scale-factor=2.00`? this would be huge for handheld devices with higher resolution displays than the Steam Deck - such as the ROG Ally which is 1920x1080p or the even more egregious Legion Go which is 2560x1600p. as far as i'm aware, the only option to do this right now is either 1: make gamescope think your panel is external with a forked version of gamescope or 2: rely on third-party extensions to access "hidden" dev options that end users should definitely not be messing with

2. adding in a way for users to define the default resolution that gamescope should use for games in an embedded context like gamescope-session, offering an easy way to bypass the 720p restriction within steam without having to go into every game entry and change Default -> Native (or whatever other resolution you'd prefer). this is probably a better option something like always defaulting to a monitor's native resolution in case people hook up 4K monitors or TVs to a Steam Deck so they're not left with 5fps in games unexpectedly.

both of these would go a long way towards improving the end user experience on handheld PCs and make it easier to ship upstream gamescope to a wider variety of devices.

and perhaps as a future suggestion - expanding this to support specifying a default audio output device for gamescope-session would be sweet. I've noticed that using the Valve provided gamescope-session can sometimes lead to the default output getting changed during session-switches to something like the internal speakers, rather than a preferred external audio playback device. accounting for that in here would give users a way to do this without messing directly with pipewire, which I think many casual linux users are unfamiliar with.

Those are good suggestions, but both of those requests are features related to steam (not gamescope).

@matte-schwartz
Copy link

Those are good suggestions, but both of those requests are features related to steam (not gamescope).

Hmm that's fair, the only vector to do this before now has been via gamescope patching which is why I put them here. I'll file them in feature requests in steam-for-linux if they don't exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants