@@ -47,29 +47,31 @@ class SteamModel extends _$SteamModel {
47
47
installLocation = install;
48
48
49
49
// global config
50
+ final file = File (steamGlobalConfig (installLocation));
51
+ globalConfig = vdfDecode (await file.readAsString ());
52
+
50
53
final fileSystem = FileWatcher (steamGlobalConfig (installLocation));
51
54
fileSystem.events.listen ((event) async {
52
55
switch (event.type) {
53
56
case ChangeType .MODIFY :
54
57
await updateGlobalConfig ();
55
58
}
56
59
});
57
- final file = File (steamGlobalConfig (installLocation));
58
- globalConfig = vdfDecode (await file.readAsString ());
59
60
60
61
// user configs
61
62
final users = await listUserDirs ();
62
63
userConfigs = new Map ();
63
64
for (final steamID in users) {
65
+ final file = File (steamUserConfig (installLocation, steamID));
66
+ userConfigs[steamID] = vdfDecode (await file.readAsString ());
67
+
64
68
final fileSystem = FileWatcher (steamUserConfig (installLocation, steamID));
65
69
fileSystem.events.listen ((event) async {
66
70
switch (event.type) {
67
71
case ChangeType .MODIFY :
68
72
await updateUserConfig (steamID);
69
73
}
70
74
});
71
- final file = File (steamUserConfig (installLocation, steamID));
72
- userConfigs[steamID] = vdfDecode (await file.readAsString ());
73
75
}
74
76
75
77
return (
@@ -103,4 +105,47 @@ class SteamModel extends _$SteamModel {
103
105
userConfigs: userConfigs,
104
106
));
105
107
}
108
+
109
+ /// Enable/disable Steam Play (Proton) for all titles globally. This is
110
+ /// disabled by default on Steam for Linux, but enabled by default on Steam
111
+ /// Deck.
112
+ Future <void > enableSteamPlay (
113
+ {required bool enable, String ? protonVersion}) async {
114
+ Map <String , dynamic > config = Map .from (globalConfig);
115
+ if (enable) {
116
+ config['InstallConfigStore' ]['Software' ]['Valve' ]['Steam' ]
117
+ ['CompatToolMapping' ]['0' ] = {
118
+ 'name' : protonVersion ?? 'proton_experimental' ,
119
+ 'config' : '' ,
120
+ 'priority' : '75'
121
+ };
122
+ } else {
123
+ config['InstallConfigStore' ]['Software' ]['Valve' ]['Steam' ]
124
+ ['CompatToolMapping' ] = {};
125
+ }
126
+
127
+ final file = File (steamGlobalConfig (installLocation));
128
+ await file.writeAsString (vdf.encode (config));
129
+ }
130
+
131
+ /// Get a map of installed Steam apps for the given user.
132
+ Future <Map <String , dynamic >> listApps ({required String steamID}) async {
133
+ Map <String , dynamic > config = Map .from (userConfigs[steamID]! );
134
+ Map <dynamic , dynamic > apps =
135
+ config['UserLocalConfigStore' ]['Software' ]['Valve' ]['Steam' ]['apps' ];
136
+ return apps.cast <String , dynamic >();
137
+ }
138
+
139
+ /// Set the raw launch options for a specific app.
140
+ Future <void > setGameLaunchOptions ({
141
+ required String steamID,
142
+ required String appID,
143
+ required String options,
144
+ }) async {
145
+ Map <String , dynamic > config = Map .from (userConfigs[steamID]! );
146
+ config['UserLocalConfigStore' ]['Software' ]['Valve' ]['Steam' ]['apps' ][appID]
147
+ ['LaunchOptions' ] = options;
148
+ final file = File (steamUserConfig (installLocation, steamID));
149
+ await file.writeAsString (vdf.encode (config));
150
+ }
106
151
}
0 commit comments