From 22b95f930d3e98ed62530e1099d7831cb5b951a6 Mon Sep 17 00:00:00 2001 From: Leigh MacDonald Date: Thu, 2 Mar 2023 18:16:17 -0700 Subject: [PATCH] Add linux process check --- internal/platform/linux.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/platform/linux.go b/internal/platform/linux.go index 680614a..f0df171 100644 --- a/internal/platform/linux.go +++ b/internal/platform/linux.go @@ -12,6 +12,7 @@ import ( var ( DefaultSteamRoot = "~/.local/share/steam/Steam" DefaultTF2Root = "~/.local/share/steam/Steam/steamapps/common/Team Fortress 2/tf" + BinaryName = "hl2" TF2RootValidationFile = "bin/client.so" ) @@ -35,6 +36,20 @@ func OpenFolder(dir string) { } } +func IsGameRunning() bool { + processes, errPs := ps.Processes() + if errPs != nil { + log.Printf("Failed to get process list: %v\n", errPs) + return false + } + for _, process := range processes { + if process.Executable() == BinaryName { + return true + } + } + return false +} + func init() { // We cant really auto-detect this stuff in the same manner line on windows with the registry // so linux users may need to configure this manually.