Skip to content

Commit 7ca7a81

Browse files
committed
Add final bits
1 parent 179a84e commit 7ca7a81

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

ArchiSteamFarm/Core/OS.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ internal static async Task CoreInit(bool minimized, bool systemRequired) {
8080
}
8181

8282
if (OperatingSystem.IsLinux()) {
83-
// TODO: Check systemRequired here once we're done testing
84-
await LinuxKeepSystemActive().ConfigureAwait(false);
83+
if (systemRequired) {
84+
await LinuxKeepSystemActive().ConfigureAwait(false);
85+
}
8586
}
8687

8788
if (OperatingSystem.IsWindows()) {
@@ -326,14 +327,22 @@ private static async Task LinuxKeepSystemActive() {
326327

327328
MessageBuffer message = writer.CreateMessage();
328329

329-
// Inhibit() returns a single value, a file descriptor that encapsulates the lock
330-
InhibitLock = await connection.CallMethodAsync(
331-
message, static (response, _) => {
332-
Reader reader = response.GetBodyReader();
330+
try {
331+
// Inhibit() returns a single value, a file descriptor that encapsulates the lock
332+
InhibitLock = await connection.CallMethodAsync(
333+
message, static (response, _) => {
334+
Reader reader = response.GetBodyReader();
335+
336+
return reader.ReadHandle<SafeFileHandle>();
337+
}
338+
).ConfigureAwait(false);
339+
} catch (DBusException e) {
340+
// Possible if login manager does not support inhibit, although that should be super rare
341+
ASF.ArchiLogger.LogGenericDebuggingException(e);
342+
ASF.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(nameof(connection)));
333343

334-
return reader.ReadHandle<SafeFileHandle>();
335-
}
336-
).ConfigureAwait(false);
344+
return;
345+
}
337346

338347
if (InhibitLock == null) {
339348
ASF.ArchiLogger.LogGenericError(Strings.FormatWarningFailedWithError(nameof(InhibitLock)));

0 commit comments

Comments
 (0)