Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cosmic: Provide CosmicConfigEntry impl, use _ in property names #254

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cosmic-comp-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
cosmic-config = { git = "https://github.com/pop-os/libcosmic/" }
input = "0.8.3"
serde = { version = "1", features = ["derive"] }
10 changes: 5 additions & 5 deletions cosmic-comp-config/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pub use input::{AccelProfile, ClickMethod, ScrollMethod, TapButtonMap};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct InputConfig {
pub state: DeviceState,
#[serde(skip_serializing_if = "Option::is_none", default)]
Expand All @@ -29,14 +29,14 @@ pub struct InputConfig {
pub tap_config: Option<TapConfig>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct AccelConfig {
#[serde(with = "AccelProfileDef")]
pub profile: Option<AccelProfile>,
pub speed: f64,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
pub struct ScrollConfig {
#[serde(with = "ScrollMethodDef")]
pub method: Option<ScrollMethod>,
Expand All @@ -45,7 +45,7 @@ pub struct ScrollConfig {
pub scroll_factor: Option<f64>,
}

#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum DeviceState {
Enabled,
Disabled,
Expand All @@ -58,7 +58,7 @@ impl Default for DeviceState {
}
}

#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TapConfig {
pub enabled: bool,
#[serde(with = "TapButtonMapDef")]
Expand Down
13 changes: 12 additions & 1 deletion cosmic-comp-config/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-only

use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

pub mod input;
pub mod workspace;

#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, PartialEq, CosmicConfigEntry)]
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,
}

#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct XkbConfig {
pub rules: String,
pub model: String,
Expand Down
2 changes: 1 addition & 1 deletion cosmic-comp-config/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn default_workspace_layout() -> WorkspaceLayout {
WorkspaceLayout::Vertical
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WorkspaceConfig {
pub workspace_mode: WorkspaceMode,
pub workspace_amount: WorkspaceAmount,
Expand Down
20 changes: 10 additions & 10 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ impl Config {
Config {
static_conf: Self::load_static(xdg.as_ref(), workspace.workspace_layout),
dynamic_conf: Self::load_dynamic(xdg.as_ref()),
xkb: get_config(&config, "xkb-config"),
input_default: get_config(&config, "input-default"),
input_touchpad: get_config(&config, "input-touchpad"),
input_devices: get_config(&config, "input-devices"),
xkb: get_config(&config, "xkb_config"),
input_default: get_config(&config, "input_default"),
input_touchpad: get_config(&config, "input_touchpad"),
input_devices: get_config(&config, "input_devices"),
workspace,
config,
}
Expand Down Expand Up @@ -517,18 +517,18 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
}
state.common.config.xkb = value;
}
"input-default" => {
let value = get_config::<InputConfig>(&config, "input-default");
"input_default" => {
let value = get_config::<InputConfig>(&config, "input_default");
state.common.config.input_default = value;
update_input(state);
}
"input-touchpad" => {
let value = get_config::<InputConfig>(&config, "input-touchpad");
"input_touchpad" => {
let value = get_config::<InputConfig>(&config, "input_touchpad");
state.common.config.input_touchpad = value;
update_input(state);
}
"input-devices" => {
let value = get_config::<HashMap<String, InputConfig>>(&config, "input-devices");
"input_devices" => {
let value = get_config::<HashMap<String, InputConfig>>(&config, "input_devices");
state.common.config.input_devices = value;
update_input(state);
}
Expand Down