Skip to content

Commit

Permalink
Add linux process check
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmacdonald committed Mar 3, 2023
1 parent c063f12 commit 22b95f9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/platform/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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.
Expand Down

0 comments on commit 22b95f9

Please sign in to comment.