Use new config from cosmic-settings-config
This commit is contained in:
parent
ec86fc33e0
commit
5fe9ba29eb
5 changed files with 28 additions and 25 deletions
2
Makefile
2
Makefile
|
|
@ -24,7 +24,7 @@ endif
|
||||||
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
|
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
|
||||||
|
|
||||||
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
|
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
|
||||||
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicComp/v1/tiling_exceptions"
|
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults"
|
||||||
|
|
||||||
all: extract-vendor
|
all: extract-vendor
|
||||||
cargo build $(ARGS)
|
cargo build $(ARGS)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ pub struct CosmicCompConfig {
|
||||||
pub input_touchpad: input::InputConfig,
|
pub input_touchpad: input::InputConfig,
|
||||||
pub input_devices: HashMap<String, input::InputConfig>,
|
pub input_devices: HashMap<String, input::InputConfig>,
|
||||||
pub xkb_config: XkbConfig,
|
pub xkb_config: XkbConfig,
|
||||||
pub tiling_exceptions: Vec<ApplicationExceptions>,
|
|
||||||
/// Autotiling enabled
|
/// Autotiling enabled
|
||||||
pub autotile: bool,
|
pub autotile: bool,
|
||||||
/// Determines the behavior of the autotile variable
|
/// Determines the behavior of the autotile variable
|
||||||
|
|
@ -34,12 +33,6 @@ pub struct CosmicCompConfig {
|
||||||
pub descale_xwayland: bool,
|
pub descale_xwayland: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
|
||||||
pub struct ApplicationExceptions {
|
|
||||||
pub appid: String,
|
|
||||||
pub titles: Vec<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for CosmicCompConfig {
|
impl Default for CosmicCompConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -60,7 +53,6 @@ impl Default for CosmicCompConfig {
|
||||||
},
|
},
|
||||||
input_devices: Default::default(),
|
input_devices: Default::default(),
|
||||||
xkb_config: Default::default(),
|
xkb_config: Default::default(),
|
||||||
tiling_exceptions: Default::default(),
|
|
||||||
autotile: Default::default(),
|
autotile: Default::default(),
|
||||||
autotile_behavior: Default::default(),
|
autotile_behavior: Default::default(),
|
||||||
active_hint: true,
|
active_hint: true,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
||||||
use cosmic_settings_config::{shortcuts, Shortcuts};
|
use cosmic_settings_config::{shortcuts, Shortcuts, window_rules};
|
||||||
|
use cosmic_settings_config::window_rules::ApplicationException;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smithay::wayland::xdg_activation::XdgActivationState;
|
use smithay::wayland::xdg_activation::XdgActivationState;
|
||||||
pub use smithay::{
|
pub use smithay::{
|
||||||
|
|
@ -53,6 +54,8 @@ pub struct Config {
|
||||||
pub settings_context: cosmic_config::Config,
|
pub settings_context: cosmic_config::Config,
|
||||||
/// Key bindings from `com.system76.CosmicSettings.Shortcuts`
|
/// Key bindings from `com.system76.CosmicSettings.Shortcuts`
|
||||||
pub shortcuts: Shortcuts,
|
pub shortcuts: Shortcuts,
|
||||||
|
// Tiling exceptions from `com.system76.CosmicSettings.WindowRules`
|
||||||
|
pub tiling_exceptions: Vec<ApplicationException>,
|
||||||
/// System actions from `com.system76.CosmicSettings.Shortcuts`
|
/// System actions from `com.system76.CosmicSettings.Shortcuts`
|
||||||
pub system_actions: BTreeMap<shortcuts::action::System, String>,
|
pub system_actions: BTreeMap<shortcuts::action::System, String>,
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +208,9 @@ impl Config {
|
||||||
let system_actions = shortcuts::system_actions(&config);
|
let system_actions = shortcuts::system_actions(&config);
|
||||||
let mut shortcuts = shortcuts::shortcuts(&settings_context);
|
let mut shortcuts = shortcuts::shortcuts(&settings_context);
|
||||||
|
|
||||||
|
let tiling_context = window_rules::context().expect("Failed to load window rules config");
|
||||||
|
let tiling_exceptions = window_rules::tiling_exceptions(&tiling_context);
|
||||||
|
|
||||||
// Add any missing default shortcuts recommended by the compositor.
|
// Add any missing default shortcuts recommended by the compositor.
|
||||||
key_bindings::add_default_bindings(&mut shortcuts, workspace.workspace_layout);
|
key_bindings::add_default_bindings(&mut shortcuts, workspace.workspace_layout);
|
||||||
|
|
||||||
|
|
@ -251,6 +257,7 @@ impl Config {
|
||||||
settings_context,
|
settings_context,
|
||||||
shortcuts,
|
shortcuts,
|
||||||
system_actions,
|
system_actions,
|
||||||
|
tiling_exceptions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic_settings_config::shortcuts::action::Orientation;
|
use cosmic_settings_config::shortcuts::action::Orientation;
|
||||||
use regex::RegexSet;
|
use regex::{Regex, RegexSet};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
desktop::WindowSurface,
|
desktop::WindowSurface,
|
||||||
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceData},
|
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceData},
|
||||||
xwayland::xwm::WmWindowType,
|
xwayland::xwm::WmWindowType,
|
||||||
};
|
};
|
||||||
|
use tracing::warn;
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
|
|
@ -62,21 +63,28 @@ pub struct TilingExceptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TilingExceptions {
|
impl TilingExceptions {
|
||||||
pub fn new(config: &Config) -> Result<Self, regex::Error> {
|
pub fn new(config: &Config) -> Self {
|
||||||
let mut app_ids = Vec::new();
|
let mut app_ids = Vec::new();
|
||||||
let mut titles = Vec::new();
|
let mut titles = Vec::new();
|
||||||
|
|
||||||
for app in &config.cosmic_conf.tiling_exceptions {
|
for exception in &config.tiling_exceptions {
|
||||||
for title in &app.titles {
|
if let Err(e) = Regex::new(&exception.appid) {
|
||||||
app_ids.push(app.appid.clone());
|
warn!("Invalid regex for appid: {}, {}", exception.appid, e);
|
||||||
titles.push(title.clone());
|
continue;
|
||||||
}
|
}
|
||||||
|
if let Err(e) = Regex::new(&exception.title) {
|
||||||
|
warn!("Invalid regex for title: {}, {}", exception.appid, e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
app_ids.push(exception.appid.clone());
|
||||||
|
titles.push(exception.title.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Self {
|
||||||
app_ids: RegexSet::new(app_ids)?,
|
app_ids: RegexSet::new(app_ids).unwrap(),
|
||||||
titles: RegexSet::new(titles)?,
|
titles: RegexSet::new(titles).unwrap(),
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use std::{
|
||||||
sync::atomic::Ordering,
|
sync::atomic::Ordering,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use tracing::error;
|
|
||||||
use wayland_backend::server::ClientId;
|
use wayland_backend::server::ClientId;
|
||||||
|
|
||||||
use crate::wayland::protocols::workspace::WorkspaceCapabilities;
|
use crate::wayland::protocols::workspace::WorkspaceCapabilities;
|
||||||
|
|
@ -1236,10 +1235,7 @@ impl Shell {
|
||||||
pub fn new(config: &Config) -> Self {
|
pub fn new(config: &Config) -> Self {
|
||||||
let theme = cosmic::theme::system_preference();
|
let theme = cosmic::theme::system_preference();
|
||||||
|
|
||||||
let tiling_exceptions = layout::TilingExceptions::new(config).unwrap_or_else(|e| {
|
let tiling_exceptions = layout::TilingExceptions::new(config);
|
||||||
error!(?e, "Could not load tiling exceptions, using default");
|
|
||||||
layout::TilingExceptions::default()
|
|
||||||
});
|
|
||||||
|
|
||||||
Shell {
|
Shell {
|
||||||
workspaces: Workspaces::new(config, theme.clone()),
|
workspaces: Workspaces::new(config, theme.clone()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue