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::{GameTool, ToolAvailability, ToolCategory, ToolConfig, WrapperEntry, which};
9
10pub static GAMEMODE: GameMode = GameMode;
11
12pub struct GameMode;
13
14impl GameTool for GameMode {
15    fn tool_id(&self) -> &'static str {
16        "gamemode"
17    }
18
19    fn display_name(&self) -> &'static str {
20        "GameMode"
21    }
22
23    fn category(&self) -> ToolCategory {
24        ToolCategory::Performance
25    }
26
27    fn description(&self) -> &'static str {
28        "Feral GameMode wrapper that applies system performance tuning while the game runs."
29    }
30
31    fn settings_schema(&self) -> Vec<super::ToolSettingSpec> {
32        vec![
33            super::ToolSettingSpec::read_only(
34                "wrapper",
35                "Wrapper",
36                "Uses gamemoderun before the game executable when enabled.",
37            )
38            .section("Wrapper"),
39        ]
40    }
41
42    fn detect_available(&self) -> ToolAvailability {
43        #[cfg(not(target_os = "linux"))]
44        {
45            return ToolAvailability::NotInstalled {
46                install_hint: "GameMode is only available on Linux".into(),
47            };
48        }
49
50        #[cfg(target_os = "linux")]
51        if which("gamemoderun").is_some() {
52            ToolAvailability::Available { version: None }
53        } else {
54            ToolAvailability::NotInstalled {
55                install_hint: "Install gamemode from your package manager".into(),
56            }
57        }
58    }
59
60    fn env_vars(&self, _config: &ToolConfig) -> SmallVec<[(String, String); 4]> {
61        SmallVec::new()
62    }
63
64    fn wrapper_command(&self, _config: &ToolConfig) -> Option<WrapperEntry> {
65        Some(WrapperEntry {
66            exe: "gamemoderun".into(),
67            args: String::new(),
68        })
69    }
70
71    fn default_config(&self) -> ToolConfig {
72        ToolConfig::new("gamemode")
73    }
74}