Skip to content

Conversation

@Wurielle
Copy link

@Wurielle Wurielle commented Feb 8, 2026

Closes #174

Here's my proposed implementation to allow the edition of the OptiScaler.ini config file using environment variables as described in #174

I propose that environment variables follow the naming convention of sections, keys and values in the OptiScaler.ini file provided by the OptiScaler team so that an environment variable is constructed like the following: OptiScaler_Section_Key=Value

For example, in order to set the following in the OptiScaler.ini config file:

; -------------------------------------------------------
[Upscalers]
; -------------------------------------------------------
; Select Upscaler for Dx11 games
; fsr22 (native DX11), fsr31 (native DX11), xess (native DX11, Arc only), xess_12 (dx11on12), fsr21_12 (dx11on12), fsr22_12 (dx11on12), fsr31_12 (dx11on12, FSR4), dlss - Default (auto) is fsr22
Dx11Upscaler=fsr31_12

; Select Upscaler for Dx12 games
; xess, fsr21, fsr22, fsr31 (also for FSR4), dlss - Default (auto) is xess
Dx12Upscaler=fsr31

You would provide the following launch options:

OptiScaler_Upscalers_Dx11Upscaler=fsr31_12 OptiScaler_Upscalers_Dx12Upscaler=fsr31 ~/fgmod/fgmod %command%

This has been tested on the v0.13.0 tag as there are some issues with OptiScaler in more recent commits, see #162

@Wurielle
Copy link
Author

Here's a build based on the v0.13.0 tag that contains the feature if you wish to test quickly: https://github.com/Wurielle/Decky-Framegen/releases/tag/v0.13.0-next.1

@xXJSONDeruloXx
Copy link
Owner

xXJSONDeruloXx commented Feb 10, 2026

This is great! I'd like to propose revising the keys to be shorter given we are on devices with touchscreen keyboards. So no need to prepend with OptiScaler, and do we need to prepend section name too?

I think we could get away with just the pure keys as they exist in the ini

updated_key = False

# Regex to match [Section] and Key=Value
section_pattern = re.compile(rf'^\s*\[{re.escape(section_target)}\]\s*')
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need to be concerned about section, only relevant key. Unless there's matching key names under diff sections which I doubt

Copy link
Author

Choose a reason for hiding this comment

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

There are indeed duplicate keys between sections in the OptiScaler.ini config file which is why I decided to search by section to stay compliant. Enabled and LibraryPath are in multiple sections for example. There are also some properties that are too ambiguous and could potentially be picked up by other processes like LogLevel in the Log section.

I agree however that properties like Dx11Upscaler are very specific and shouldn't collide with any other process. They are also hard enough to type that it would be worth it to not have to type more than what's necessary. There's also a hyphenated section called "V-Sync" that I noticed today, I should investigate how to support that one properly.

So just to summerize:

  • Properties that appear multiple times should be prefixed with their section name to target them properly
  • Some properties do not need to be prefixed with either OptiScaler or their section name
  • Everything should work without the OptiScaler prefix

I'll try to use configparser to get a list of all properties in OptiScaler.ini and match them with available env variables and skip properties that appear multiple times as they will need to be prefixed with their section name to be targeted properly. I'll still support env variables prefixed with secntion names for all properties anyway and for those who desire to avoid collision with other processes entirely I'll keep the support for the OptiScaler prefix if it doesn't slow down the script too much. If you want me to not keep it at all I'll just remove it, it's just to make sure all edge cases are covered. 🙂

@Wurielle
Copy link
Author

This is great! I'd like to propose revising the keys to be shorter given we are on devices with touchscreen keyboards. So no need to prepend with OptiScaler, and do we need to prepend section name too?

I think we could get away with just the pure keys as they exist in the ini

I agree the variable names were too long for my taste as well, I have an idea to make them as close as possible to the length of keys defined in the OptiScaler.ini config file but there are limitation that I'll detail in the comment above 🙂

@Wurielle
Copy link
Author

Wurielle commented Feb 10, 2026

Now the script supports optional prefixes but be aware that case sensitivity is important so that PATH and Path don't match.

The user will have multiple ways to provide env variables:

  • OptiScaler_Upscalers_Dx12Upscaler=fsr31 which is safest and foolproof
  • FrameGen_Enabled=true the section name is required here because Enabled appears in multiple sections
  • Upscalers_Dx12Upscaler=fsr31 section name is optional but the user can still provide it if they want
  • Dx12Upscaler=fsr31 short and easiest but has chances to collide with other env variables

I would recommend to encourage the user to at least provide Section_Key=value just to be sure but specific keys like Dx12Upscaler will still work.

I have a little bit of difficulty to support the V-Sync section so I'll take another look tomorrow while waiting for any comment.

Thank you again for letting me look into this feature 🙂

@Wurielle
Copy link
Author

Wurielle commented Feb 11, 2026

Added support for section names containing -and .. Now for keys in the V-Sync section we can provide VSync_OverrideVsync or just OverrideVsync for example.

I'm gonna do more extensive testing on my steam deck tonight to verify any side effect. ✌️

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.

[Feature Request]: Allow to edit the OptiScaler.ini config using environment variables (with PR)

2 participants