Repository navigation
feat: close Big Picture and quit Steam when going back to the PC #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e743b5
feat: close Big Picture and quit Steam when going back to the PC
lippdev cc3d04e
docs: add PR number to the Steam close changelog item
lippdev 9585105
Merge remote-tracking branch 'origin/main' into feat/close-steam-on-r…
lippdev 7bc05c8
fix: handle unknown Steam game state in shutdown log
lippdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| using System.Diagnostics; | ||
| using Microsoft.Win32; | ||
|
|
||
| namespace ConsoleMode.Services; | ||
|
|
||
| /// <summary> | ||
| /// Talks to the Steam client about the end of a session: is it running, is a game running, and the | ||
| /// request to quit. Quitting is Steam's own "-shutdown" (what its Exit menu does): it is asked to close, | ||
| /// never killed, so it can save and leave cleanly. | ||
| /// </summary> | ||
| public static class SteamSession | ||
| { | ||
| private const string SteamKey = @"Software\Valve\Steam"; | ||
|
|
||
| public static bool IsRunning() | ||
| { | ||
| var processes = Process.GetProcessesByName("steam"); | ||
| try { return processes.Length > 0; } | ||
| finally { foreach (var p in processes) p.Dispose(); } | ||
| } | ||
|
|
||
| /// <summary>The id of the game Steam is running, 0 if none, or null if the state is unknown.</summary> | ||
| public static int? RunningAppId() | ||
| { | ||
| try | ||
| { | ||
| using var key = Registry.CurrentUser.OpenSubKey(SteamKey); | ||
| return SteamShutdown.ParseRunningAppId(key?.GetValue("RunningAppID")); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| AppLog.Write($"Steam: RunningAppID: {ex.Message}"); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| public static string? FindSteamExe() | ||
| { | ||
| try | ||
| { | ||
| using var key = Registry.CurrentUser.OpenSubKey(SteamKey); | ||
| var exe = key?.GetValue("SteamExe") as string; | ||
| if (!string.IsNullOrWhiteSpace(exe) && File.Exists(exe)) return Path.GetFullPath(exe); | ||
| var folder = key?.GetValue("SteamPath") as string; | ||
| if (!string.IsNullOrWhiteSpace(folder)) | ||
| { | ||
| var candidate = Path.Combine(folder, "steam.exe"); | ||
| if (File.Exists(candidate)) return Path.GetFullPath(candidate); | ||
| } | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| AppLog.Write($"Steam: caminho: {ex.Message}"); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /// <summary>Asks Steam to exit the normal way. Returns whether the request was sent; it does not wait.</summary> | ||
| public static bool RequestShutdown() | ||
| { | ||
| var exe = FindSteamExe(); | ||
| if (exe is null) | ||
| { | ||
| AppLog.Write("Steam: não achei o steam.exe para fechar"); | ||
| return false; | ||
| } | ||
| try | ||
| { | ||
| Process.Start(new ProcessStartInfo { FileName = exe, Arguments = "-shutdown", UseShellExecute = false, CreateNoWindow = true })?.Dispose(); | ||
| return true; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| AppLog.Write($"Steam: pedido de fechar falhou: {ex.Message}"); | ||
| return false; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.