1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-20 08:11:03 +02:00

feat: ability to set bar layer and exclusive zone

This commit is contained in:
Jake Stanger 2024-06-13 21:42:40 +01:00
parent c28de8d902
commit aa45396062
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
7 changed files with 145 additions and 36 deletions

View file

@ -35,6 +35,37 @@ impl<'de> Deserialize<'de> for MonitorConfig {
}
}
pub fn deserialize_layer<'de, D>(deserializer: D) -> Result<gtk_layer_shell::Layer, D::Error>
where
D: serde::Deserializer<'de>,
{
use gtk_layer_shell::Layer;
let value = Option::<String>::deserialize(deserializer)?;
value
.map(|v| match v.as_str() {
"background" => Ok(Layer::Background),
"bottom" => Ok(Layer::Bottom),
"top" => Ok(Layer::Top),
"overlay" => Ok(Layer::Overlay),
_ => Err(serde::de::Error::custom("invalid value for orientation")),
})
.unwrap_or(Ok(Layer::Top))
}
#[cfg(feature = "schema")]
pub fn schema_layer(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
use schemars::JsonSchema;
let mut schema: schemars::schema::SchemaObject = <String>::json_schema(gen).into();
schema.enum_values = Some(vec![
"background".into(),
"bottom".into(),
"top".into(),
"overlay".into(),
]);
schema.into()
}
impl BarPosition {
/// Gets the orientation the bar and widgets should use
/// based on this position.