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.