config: allow disabling color-management
This commit is contained in:
parent
c66f5798b7
commit
248eb324a5
24 changed files with 388 additions and 9 deletions
|
|
@ -11,7 +11,10 @@ use {
|
|||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
parsers::config::{ConfigParser, ConfigParserError},
|
||||
parsers::{
|
||||
color_management::ColorManagement,
|
||||
config::{ConfigParser, ConfigParserError},
|
||||
},
|
||||
},
|
||||
toml::{self},
|
||||
},
|
||||
|
|
@ -358,6 +361,7 @@ pub struct Config {
|
|||
pub libei: Libei,
|
||||
pub ui_drag: UiDrag,
|
||||
pub xwayland: Option<Xwayland>,
|
||||
pub color_management: Option<ColorManagement>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use {
|
|||
|
||||
pub mod action;
|
||||
mod color;
|
||||
pub mod color_management;
|
||||
pub mod config;
|
||||
mod connector;
|
||||
mod connector_match;
|
||||
|
|
|
|||
48
toml-config/src/config/parsers/color_management.rs
Normal file
48
toml-config/src/config/parsers/color_management.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use {
|
||||
crate::{
|
||||
config::{
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, bol, opt},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
},
|
||||
toml::{
|
||||
toml_span::{DespanExt, Span, Spanned},
|
||||
toml_value::Value,
|
||||
},
|
||||
},
|
||||
indexmap::IndexMap,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ColorManagementParserError {
|
||||
#[error(transparent)]
|
||||
Expected(#[from] UnexpectedDataType),
|
||||
#[error(transparent)]
|
||||
Extract(#[from] ExtractorError),
|
||||
}
|
||||
|
||||
pub struct ColorManagementParser<'a>(pub &'a Context<'a>);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColorManagement {
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
impl Parser for ColorManagementParser<'_> {
|
||||
type Value = ColorManagement;
|
||||
type Error = ColorManagementParserError;
|
||||
const EXPECTED: &'static [DataType] = &[DataType::Table];
|
||||
|
||||
fn parse_table(
|
||||
&mut self,
|
||||
span: Span,
|
||||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (enabled,) = ext.extract((opt(bol("enabled")),))?;
|
||||
Ok(ColorManagement {
|
||||
enabled: enabled.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ use {
|
|||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
parsers::{
|
||||
action::ActionParser,
|
||||
color_management::ColorManagementParser,
|
||||
connector::ConnectorsParser,
|
||||
drm_device::DrmDevicesParser,
|
||||
drm_device_match::DrmDeviceMatchParser,
|
||||
|
|
@ -117,6 +118,7 @@ impl Parser for ConfigParser<'_> {
|
|||
ui_drag_val,
|
||||
xwayland_val,
|
||||
),
|
||||
(color_management_val,),
|
||||
) = ext.extract((
|
||||
(
|
||||
opt(val("keymap")),
|
||||
|
|
@ -154,6 +156,7 @@ impl Parser for ConfigParser<'_> {
|
|||
opt(val("ui-drag")),
|
||||
opt(val("xwayland")),
|
||||
),
|
||||
(opt(val("color-management")),),
|
||||
))?;
|
||||
let mut keymap = None;
|
||||
if let Some(value) = keymap_val {
|
||||
|
|
@ -366,6 +369,18 @@ impl Parser for ConfigParser<'_> {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut color_management = None;
|
||||
if let Some(value) = color_management_val {
|
||||
match value.parse(&mut ColorManagementParser(self.0)) {
|
||||
Ok(v) => color_management = Some(v),
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"Could not parse the color-management settings: {}",
|
||||
self.0.error(e)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Config {
|
||||
keymap,
|
||||
repeat_rate,
|
||||
|
|
@ -396,6 +411,7 @@ impl Parser for ConfigParser<'_> {
|
|||
libei,
|
||||
ui_drag,
|
||||
xwayland,
|
||||
color_management,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ use {
|
|||
is_reload,
|
||||
keyboard::{Keymap, ModifiedKeySym},
|
||||
logging::set_log_level,
|
||||
on_devices_enumerated, on_idle, quit, reload, set_default_workspace_capture,
|
||||
set_explicit_sync_enabled, set_idle, set_idle_grace_period, set_ui_drag_enabled,
|
||||
set_ui_drag_threshold,
|
||||
on_devices_enumerated, on_idle, quit, reload, set_color_management_enabled,
|
||||
set_default_workspace_capture, set_explicit_sync_enabled, set_idle, set_idle_grace_period,
|
||||
set_ui_drag_enabled, set_ui_drag_threshold,
|
||||
status::{set_i3bar_separator, set_status, set_status_command, unset_status_command},
|
||||
switch_to_vt,
|
||||
theme::{reset_colors, reset_font, reset_sizes, set_font},
|
||||
|
|
@ -1078,6 +1078,11 @@ fn load_config(initial_load: bool, persistent: &Rc<PersistentState>) {
|
|||
set_x_scaling_mode(mode);
|
||||
}
|
||||
}
|
||||
if let Some(cm) = config.color_management {
|
||||
if let Some(enabled) = cm.enabled {
|
||||
set_color_management_enabled(enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn create_command(exec: &Exec) -> Command {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue