Step 1: Describe your environment
- OS: ALT Linux
- s-tui versions tested: 1.1.4 and 1.5.0
- Installation method: distribution package
Step 2: Describe the problem
The --refresh-rate / -r command-line option is ignored when the user has previously saved a refresh rate in the s-tui configuration.
The option was introduced in #196 to allow setting the refresh rate at launch, including for automated workflows. However, its value is currently overwritten by ~/.config/s-tui/s-tui.conf.
Step 3: Reproduce the problem
-
Start s-tui.
-
Open Visual options.
-
Set Refresh to 5.
-
Select Save settings and quit.
-
Run:
Observed result
The refresh rate remains 5 seconds, as stored in the configuration file.
Expected result
The explicitly supplied command-line value should take precedence, so the refresh rate should be 1 second.
The expected precedence is:
built-in default < saved configuration < command-line argument
Root cause
GraphController.__init__() initially assigns the command-line value:
self.refresh_rate = args.refresh_rate
It then calls _load_config(), which unconditionally overwrites it when the configuration contains GraphControl.refresh:
self.refresh_rate = str(self.conf.getfloat("GraphControl", "refresh"))
The parser also uses "2.0" as the argument default, so the application cannot distinguish between an omitted option and an explicit --refresh-rate 2.0.
The temperature threshold option already implements the expected CLI-over-config precedence.
Suggested fix
Use None as the argparse default to represent an omitted option, and apply values in this order:
- Initialize the built-in default (
2.0).
- Load the saved configuration.
- If
args.refresh_rate is not None, apply it last.
Simply moving the existing assignment after _load_config() would not be sufficient because the current argparse default would then overwrite the saved configuration even when the option was omitted.
Suggested test cases:
- no configuration and no
-r: use 2.0;
- saved configuration and no
-r: use the saved value;
- saved configuration plus
-r 1: use 1;
- saved configuration plus explicit
-r 2.0: use 2.0.
Downstream report: https://bugzilla.altlinux.org/48524
Step 1: Describe your environment
Step 2: Describe the problem
The
--refresh-rate/-rcommand-line option is ignored when the user has previously saved a refresh rate in the s-tui configuration.The option was introduced in #196 to allow setting the refresh rate at launch, including for automated workflows. However, its value is currently overwritten by
~/.config/s-tui/s-tui.conf.Step 3: Reproduce the problem
Start
s-tui.Open
Visual options.Set
Refreshto5.Select
Save settingsand quit.Run:
s-tui --refresh-rate 1Observed result
The refresh rate remains
5seconds, as stored in the configuration file.Expected result
The explicitly supplied command-line value should take precedence, so the refresh rate should be
1second.The expected precedence is:
Root cause
GraphController.__init__()initially assigns the command-line value:It then calls
_load_config(), which unconditionally overwrites it when the configuration containsGraphControl.refresh:The parser also uses
"2.0"as the argument default, so the application cannot distinguish between an omitted option and an explicit--refresh-rate 2.0.The temperature threshold option already implements the expected CLI-over-config precedence.
Suggested fix
Use
Noneas the argparse default to represent an omitted option, and apply values in this order:2.0).args.refresh_rate is not None, apply it last.Simply moving the existing assignment after
_load_config()would not be sufficient because the current argparse default would then overwrite the saved configuration even when the option was omitted.Suggested test cases:
-r: use2.0;-r: use the saved value;-r 1: use1;-r 2.0: use2.0.Downstream report: https://bugzilla.altlinux.org/48524