Add util function for boolean env vars
It's probably good to be consistent about what is recognized as "true" without copying the same code.
This commit is contained in:
parent
a4d875e35e
commit
087be20365
3 changed files with 10 additions and 10 deletions
13
src/state.rs
13
src/state.rs
|
|
@ -454,14 +454,7 @@ pub fn client_is_privileged(client: &Client) -> bool {
|
|||
}
|
||||
|
||||
fn enable_wayland_security() -> bool {
|
||||
std::env::var("COSMIC_ENABLE_WAYLAND_SECURITY")
|
||||
.map(|x| {
|
||||
x == "1"
|
||||
|| x.to_lowercase() == "true"
|
||||
|| x.to_lowercase() == "yes"
|
||||
|| x.to_lowercase() == "y"
|
||||
})
|
||||
.unwrap_or(false)
|
||||
crate::utils::env::bool_var("COSMIC_ENABLE_WAYLAND_SECURITY").unwrap_or(false)
|
||||
}
|
||||
|
||||
impl State {
|
||||
|
|
@ -524,8 +517,8 @@ impl State {
|
|||
let idle_inhibit_manager_state = IdleInhibitManagerState::new::<State>(&dh);
|
||||
let idle_inhibiting_surfaces = HashSet::new();
|
||||
|
||||
let data_control_state = std::env::var("COSMIC_DATA_CONTROL_ENABLED")
|
||||
.is_ok_and(|value| value == "1")
|
||||
let data_control_state = crate::utils::env::bool_var("COSMIC_DATA_CONTROL_ENABLED")
|
||||
.unwrap_or(false)
|
||||
.then(|| {
|
||||
DataControlState::new::<Self, _>(dh, Some(&primary_selection_state), |_| true)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue