Use cosmic-config for dynamic workspace settings

`WorkspaceAmount`, `WorkspaceMode`, and `WorkspaceLayout` can all be
changed dynamically now.
This commit is contained in:
Ian Douglas Scott 2023-09-07 13:28:08 -07:00
parent 25f5edd6cf
commit 81efd42dd5
9 changed files with 88 additions and 51 deletions

View file

@ -3,6 +3,7 @@
use serde::{Deserialize, Serialize};
pub mod input;
pub mod workspace;
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct XkbConfig {

View file

@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-3.0-only
use serde::{Deserialize, Serialize};
fn default_workspace_layout() -> WorkspaceLayout {
WorkspaceLayout::Vertical
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceConfig {
pub workspace_mode: WorkspaceMode,
pub workspace_amount: WorkspaceAmount,
#[serde(default = "default_workspace_layout")]
pub workspace_layout: WorkspaceLayout,
}
impl Default for WorkspaceConfig {
fn default() -> Self {
Self {
workspace_mode: WorkspaceMode::OutputBound,
workspace_amount: WorkspaceAmount::Dynamic,
workspace_layout: WorkspaceLayout::Vertical,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum WorkspaceAmount {
Dynamic,
Static(u8),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum WorkspaceMode {
OutputBound,
Global,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum WorkspaceLayout {
Vertical,
Horizontal,
}