Skip to main content

modde_games/tools/
gamemode.rs

1//! GameMode — Feral Interactive's performance optimization daemon.
2//!
3//! Uses `gamemoderun` as a wrapper command before the game executable.
4//! No config files or env vars needed.
5
6use smallvec::SmallVec;
7
8use super::{
9    GameTool, ToolAvailability, ToolCategory, ToolConfig, WrapperEntry, which,
10};
11
12pub static GAMEMODE: GameMode = GameMode;
13
14pub struct GameMode;
15
16impl GameTool for GameMode {
17    fn tool_id(&self) -> &'static str {
18        "gamemode"
19    }
20
21    fn display_name(&self) -> &'static str {
22        "GameMode"
23    }
24
25    fn category(&self) -> ToolCategory {
26        ToolCategory::Performance
27    }
28
29    fn detect_available(&self) -> ToolAvailability {
30        #[cfg(not(target_os = "linux"))]
31        {
32            return ToolAvailability::NotInstalled {
33                install_hint: "GameMode is only available on Linux".into(),
34            };
35        }
36
37        #[cfg(target_os = "linux")]
38        if which("gamemoderun").is_some() {
39            ToolAvailability::Available { version: None }
40        } else {
41            ToolAvailability::NotInstalled {
42                install_hint: "Install gamemode from your package manager".into(),
43            }
44        }
45    }
46
47    fn env_vars(&self, _config: &ToolConfig) -> SmallVec<[(String, String); 4]> {
48        SmallVec::new()
49    }
50
51    fn wrapper_command(&self, _config: &ToolConfig) -> Option<WrapperEntry> {
52        Some(WrapperEntry {
53            exe: "gamemoderun".into(),
54            args: String::new(),
55        })
56    }
57
58    fn default_config(&self) -> ToolConfig {
59        ToolConfig::new("gamemode")
60    }
61}