2023-08-29 13:49:41 -07:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
|
|
2023-12-20 16:52:44 -08:00
|
|
|
use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};
|
2023-08-29 13:49:41 -07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-12-20 16:52:44 -08:00
|
|
|
use std::collections::HashMap;
|
2023-08-29 13:49:41 -07:00
|
|
|
|
|
|
|
|
pub mod input;
|
2023-09-07 13:28:08 -07:00
|
|
|
pub mod workspace;
|
2023-08-29 13:49:41 -07:00
|
|
|
|
2025-02-12 05:35:22 -08:00
|
|
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
|
|
|
|
pub struct KeyboardConfig {
|
|
|
|
|
/// Boot state for numlock
|
|
|
|
|
pub numlock_state: NumlockState,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
|
|
|
|
pub enum NumlockState {
|
|
|
|
|
BootOn,
|
|
|
|
|
#[default]
|
|
|
|
|
BootOff,
|
|
|
|
|
LastBoot,
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-08 14:25:18 -05:00
|
|
|
#[derive(Clone, Debug, PartialEq, CosmicConfigEntry)]
|
|
|
|
|
#[version = 1]
|
2023-12-20 16:52:44 -08:00
|
|
|
pub struct CosmicCompConfig {
|
|
|
|
|
pub workspaces: workspace::WorkspaceConfig,
|
|
|
|
|
pub input_default: input::InputConfig,
|
|
|
|
|
pub input_touchpad: input::InputConfig,
|
|
|
|
|
pub input_devices: HashMap<String, input::InputConfig>,
|
|
|
|
|
pub xkb_config: XkbConfig,
|
2025-02-12 05:35:22 -08:00
|
|
|
pub keyboard_config: KeyboardConfig,
|
2024-02-08 14:25:18 -05:00
|
|
|
/// Autotiling enabled
|
|
|
|
|
pub autotile: bool,
|
|
|
|
|
/// Determines the behavior of the autotile variable
|
|
|
|
|
/// If set to Global, autotile applies to all windows in all workspaces
|
|
|
|
|
/// If set to PerWorkspace, autotile only applies to new windows, and new workspaces
|
|
|
|
|
pub autotile_behavior: TileBehavior,
|
|
|
|
|
/// Active hint enabled
|
|
|
|
|
pub active_hint: bool,
|
2024-09-04 11:13:59 -05:00
|
|
|
/// Enables changing keyboard focus to windows when the cursor passes into them
|
|
|
|
|
pub focus_follows_cursor: bool,
|
|
|
|
|
/// Enables warping the cursor to the focused window when focus changes due to keyboard input
|
|
|
|
|
pub cursor_follows_focus: bool,
|
|
|
|
|
/// The delay in milliseconds before focus follows mouse (if enabled)
|
|
|
|
|
pub focus_follows_cursor_delay: u64,
|
2024-08-23 18:26:08 +02:00
|
|
|
/// Let X11 applications scale themselves
|
|
|
|
|
pub descale_xwayland: bool,
|
2025-02-14 21:58:09 +11:00
|
|
|
/// The threshold before windows snap themselves to output edges
|
|
|
|
|
pub edge_snap_threshold: u32,
|
2024-02-08 14:25:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for CosmicCompConfig {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
workspaces: Default::default(),
|
|
|
|
|
input_default: Default::default(),
|
2024-07-31 06:04:08 +02:00
|
|
|
// By default, enable tap-to-click and disable-while-typing.
|
|
|
|
|
input_touchpad: input::InputConfig {
|
|
|
|
|
state: input::DeviceState::Enabled,
|
|
|
|
|
click_method: Some(input::ClickMethod::Clickfinger),
|
|
|
|
|
disable_while_typing: Some(true),
|
|
|
|
|
tap_config: Some(input::TapConfig {
|
|
|
|
|
enabled: true,
|
|
|
|
|
button_map: Some(input::TapButtonMap::LeftRightMiddle),
|
|
|
|
|
drag: true,
|
|
|
|
|
drag_lock: false,
|
|
|
|
|
}),
|
|
|
|
|
..Default::default()
|
|
|
|
|
},
|
2024-02-08 14:25:18 -05:00
|
|
|
input_devices: Default::default(),
|
|
|
|
|
xkb_config: Default::default(),
|
2025-02-12 05:35:22 -08:00
|
|
|
keyboard_config: Default::default(),
|
2024-02-08 14:25:18 -05:00
|
|
|
autotile: Default::default(),
|
|
|
|
|
autotile_behavior: Default::default(),
|
|
|
|
|
active_hint: true,
|
2024-09-04 11:13:59 -05:00
|
|
|
focus_follows_cursor: false,
|
|
|
|
|
cursor_follows_focus: false,
|
|
|
|
|
focus_follows_cursor_delay: 250,
|
2024-08-23 18:26:08 +02:00
|
|
|
descale_xwayland: false,
|
2025-02-14 21:58:09 +11:00
|
|
|
edge_snap_threshold: 0,
|
2024-02-08 14:25:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default, Copy, Clone, PartialEq, Deserialize, Serialize)]
|
|
|
|
|
pub enum TileBehavior {
|
|
|
|
|
#[default]
|
|
|
|
|
Global,
|
|
|
|
|
PerWorkspace,
|
2023-12-20 16:52:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
2023-08-29 13:49:41 -07:00
|
|
|
pub struct XkbConfig {
|
|
|
|
|
pub rules: String,
|
|
|
|
|
pub model: String,
|
|
|
|
|
pub layout: String,
|
|
|
|
|
pub variant: String,
|
|
|
|
|
pub options: Option<String>,
|
2024-05-19 18:19:43 +02:00
|
|
|
#[serde(default = "default_repeat_delay")]
|
|
|
|
|
pub repeat_delay: u32,
|
|
|
|
|
#[serde(default = "default_repeat_rate")]
|
|
|
|
|
pub repeat_rate: u32,
|
2023-08-29 13:49:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for XkbConfig {
|
|
|
|
|
fn default() -> XkbConfig {
|
|
|
|
|
XkbConfig {
|
|
|
|
|
rules: String::new(),
|
|
|
|
|
model: String::new(),
|
|
|
|
|
layout: String::new(),
|
|
|
|
|
variant: String::new(),
|
|
|
|
|
options: None,
|
2024-05-19 18:19:43 +02:00
|
|
|
repeat_delay: default_repeat_delay(),
|
|
|
|
|
repeat_rate: default_repeat_rate(),
|
2023-08-29 13:49:41 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-19 18:19:43 +02:00
|
|
|
|
|
|
|
|
fn default_repeat_rate() -> u32 {
|
|
|
|
|
25
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn default_repeat_delay() -> u32 {
|
|
|
|
|
600
|
|
|
|
|
}
|