Skip to content

Commit 236f438

Browse files
committed
add background apps toggle
1 parent 40a0041 commit 236f438

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

lib/l10n/intl_en.arb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"perfFODescription": "Fullscreen Optimizations may lead to better gaming and app performance when running in fullscreen mode",
5454
"perfOWGLabel": "Optimizations for windowed games",
5555
"perfOWGDescription": "Improves frame latency by using a new presentation model for DirectX 10 and 11 games that appear in a window or in a borderless window",
56+
"perfBALabel": "Background Apps",
57+
"perfBADescription": "Allow apps to run in the background, even when you're not using them. This will have a performance impact due to constantly running in the background. Disabling this will also disable notifications for some apps",
5658
"perfCStatesLabel": "Disable the ACPI C2 and C3 states",
5759
"perfCStatesDescription": "Disabling ACPI C-states may improve performance and latency, but it will consume more power while idle, potentially reducing battery life",
5860
"perfSectionFS": "Filesystem",

lib/l10n/untranslated.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"search",
99
"usabilitySESLabel",
1010
"usabilitySESDescription",
11+
"perfBALabel",
12+
"perfBADescription",
1113
"settingsLanguageDescription",
1214
"pageMSStore",
1315
"msstoreSearchingPackages",
@@ -25,6 +27,8 @@
2527
"search",
2628
"usabilitySESLabel",
2729
"usabilitySESDescription",
30+
"perfBALabel",
31+
"perfBADescription",
2832
"wuPauseLabel",
2933
"wuPauseDescription",
3034
"settingsLanguageDescription",
@@ -44,6 +48,8 @@
4448
"search",
4549
"usabilitySESLabel",
4650
"usabilitySESDescription",
51+
"perfBALabel",
52+
"perfBADescription",
4753
"wuPauseLabel",
4854
"wuPauseDescription",
4955
"settingsLanguageDescription",
@@ -63,6 +69,8 @@
6369
"search",
6470
"usabilitySESLabel",
6571
"usabilitySESDescription",
72+
"perfBALabel",
73+
"perfBADescription",
6674
"settingsLanguageDescription",
6775
"pageMSStore",
6876
"msstoreSearchingPackages",

lib/screens/pages/performance_page.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ class _PerformancePageState extends State<PerformancePage> {
2424
ValueNotifier<bool>(_performanceService.statusIntelTSX);
2525
late final _foBool =
2626
ValueNotifier<bool>(_performanceService.statusFullscreenOptimization);
27-
28-
/// Experimental
2927
late final _owgBool =
3028
ValueNotifier<bool>(_performanceService.statusWindowedOptimization);
29+
late final _baBool =
30+
ValueNotifier<bool>(_performanceService.statusBackgroundApps);
31+
32+
/// Experimental
33+
3134
late final _cStatesBool =
3235
ValueNotifier<bool>(_performanceService.statusCStates);
3336

@@ -105,13 +108,24 @@ class _PerformancePageState extends State<PerformancePage> {
105108
switchBool: _owgBool,
106109
function: (value) {
107110
_owgBool.value = value;
108-
109111
_owgBool.value
110112
? _performanceService.enableWindowedOptimization()
111113
: _performanceService.disableWindowedOptimization();
112114
},
113115
),
114116
],
117+
CardHighlightSwitch(
118+
icon: msicons.FluentIcons.bezier_curve_square_20_regular,
119+
label: ReviLocalizations.of(context).perfBALabel,
120+
description: ReviLocalizations.of(context).perfBADescription,
121+
switchBool: _baBool,
122+
function: (value) {
123+
_baBool.value = value;
124+
_baBool.value
125+
? _performanceService.enableBackgroundApps()
126+
: _performanceService.disableBackgroundApps();
127+
},
128+
),
115129
if (expBool.value) ...[
116130
CardHighlightSwitch(
117131
icon: msicons.FluentIcons.sleep_20_regular,

lib/services/performance_service.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,53 @@ class PerformanceService implements SetupService {
185185
'DirectXUserGlobalSettings');
186186
}
187187

188+
bool get statusBackgroundApps {
189+
return _registryUtilsService.readInt(
190+
RegistryHive.localMachine,
191+
r'Software\Policies\Microsoft\Windows\AppPrivacy',
192+
'LetAppsRunInBackground') !=
193+
2;
194+
}
195+
196+
void enableBackgroundApps() {
197+
_registryUtilsService.deleteValue(
198+
Registry.currentUser,
199+
r'Software\Microsoft\Windows\CurrentVersion\Search',
200+
'BackgroundAppGlobalToggle');
201+
_registryUtilsService.deleteValue(
202+
Registry.localMachine,
203+
r'Software\Microsoft\Windows\CurrentVersion\Search',
204+
'BackgroundAppGlobalToggle');
205+
206+
_registryUtilsService.deleteValue(
207+
Registry.currentUser,
208+
r'Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications',
209+
'GlobalUserDisabled');
210+
_registryUtilsService.deleteValue(
211+
Registry.localMachine,
212+
r'Software\Policies\Microsoft\Windows\AppPrivacy',
213+
'LetAppsRunInBackground');
214+
}
215+
216+
void disableBackgroundApps() {
217+
_registryUtilsService.writeDword(
218+
Registry.localMachine,
219+
r'Software\Microsoft\Windows\CurrentVersion\Search',
220+
'BackgroundAppGlobalToggle',
221+
0);
222+
223+
_registryUtilsService.writeDword(
224+
Registry.currentUser,
225+
r'Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications',
226+
'GlobalUserDisabled',
227+
1);
228+
_registryUtilsService.writeDword(
229+
Registry.localMachine,
230+
r'Software\Policies\Microsoft\Windows\AppPrivacy',
231+
'LetAppsRunInBackground',
232+
2);
233+
}
234+
188235
bool get statusCStates {
189236
return _registryUtilsService.readInt(RegistryHive.localMachine,
190237
r'SYSTEM\ControlSet001\Control\Processor', 'Capabilities') ==

0 commit comments

Comments
 (0)