Skip to main content

par_term_config/config/config_struct/
power_config.rs

1//! Focus/blur power saving settings.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use serde::{Deserialize, Serialize};
8
9/// Shader pausing and reduced frame rates for unfocused windows and inactive tabs.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct PowerConfig {
12    /// Pause shader animations when window loses focus
13    /// This reduces GPU usage when the terminal is not actively being viewed
14    #[serde(default = "crate::defaults::bool_true")]
15    pub pause_shaders_on_blur: bool,
16
17    /// Reduce refresh rate when window is not focused
18    /// When true, uses unfocused_fps instead of max_fps when window is blurred
19    #[serde(default = "crate::defaults::bool_true")]
20    pub pause_refresh_on_blur: bool,
21
22    /// Target FPS when window is not focused (only used if pause_refresh_on_blur is true)
23    /// Lower values save more power but may delay terminal output visibility
24    #[serde(default = "crate::defaults::unfocused_fps")]
25    pub unfocused_fps: u32,
26
27    /// Target FPS for inactive (non-visible) tabs
28    /// Inactive tabs only need enough polling to detect activity, bells, and shell exit.
29    /// Lower values significantly reduce CPU from mutex contention with many tabs open.
30    /// Default: 2 (500ms interval)
31    #[serde(default = "crate::defaults::inactive_tab_fps")]
32    pub inactive_tab_fps: u32,
33}
34
35impl Default for PowerConfig {
36    fn default() -> Self {
37        Self {
38            pause_shaders_on_blur: crate::defaults::bool_true(),
39            pause_refresh_on_blur: crate::defaults::bool_true(),
40            unfocused_fps: crate::defaults::unfocused_fps(),
41            inactive_tab_fps: crate::defaults::inactive_tab_fps(),
42        }
43    }
44}