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)"
|
||||
|
||||
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
|
||||
cargo build $(ARGS)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ pub struct CosmicCompConfig {
|
|||
pub input_touchpad: input::InputConfig,
|
||||
pub input_devices: HashMap<String, input::InputConfig>,
|
||||
pub xkb_config: XkbConfig,
|
||||
pub tiling_exceptions: Vec<ApplicationExceptions>,
|
||||
/// Autotiling enabled
|
||||
pub autotile: bool,
|
||||
/// Determines the behavior of the autotile variable
|
||||
|
|
@ -34,12 +33,6 @@ pub struct CosmicCompConfig {
|
|||
pub descale_xwayland: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct ApplicationExceptions {
|
||||
pub appid: String,
|
||||
pub titles: Vec<String>,
|
||||
}
|
||||
|
||||
impl Default for CosmicCompConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
|
@ -60,7 +53,6 @@ impl Default for CosmicCompConfig {
|
|||
},
|
||||
input_devices: Default::default(),
|
||||
xkb_config: Default::default(),
|
||||
tiling_exceptions: Default::default(),
|
||||
autotile: Default::default(),
|
||||
autotile_behavior: Default::default(),
|
||||
active_hint: true,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ use crate::{
|
|||
},
|
||||
};
|
||||
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 smithay::wayland::xdg_activation::XdgActivationState;
|
||||
pub use smithay::{
|
||||
|
|
@ -53,6 +54,8 @@ pub struct Config {
|
|||
pub settings_context: cosmic_config::Config,
|
||||
/// Key bindings from `com.system76.CosmicSettings.Shortcuts`
|
||||
pub shortcuts: Shortcuts,
|
||||
// Tiling exceptions from `com.system76.CosmicSettings.WindowRules`
|
||||
pub tiling_exceptions: Vec<ApplicationException>,
|
||||
/// System actions from `com.system76.CosmicSettings.Shortcuts`
|
||||
pub system_actions: BTreeMap<shortcuts::action::System, String>,
|
||||
}
|
||||
|
|
@ -205,6 +208,9 @@ impl Config {
|
|||
let system_actions = shortcuts::system_actions(&config);
|
||||
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.
|
||||
key_bindings::add_default_bindings(&mut shortcuts, workspace.workspace_layout);
|
||||
|
||||
|
|
@ -251,6 +257,7 @@ impl Config {
|
|||
settings_context,
|
||||
shortcuts,
|
||||
system_actions,
|
||||
tiling_exceptions,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic_settings_config::shortcuts::action::Orientation;
|
||||
use regex::RegexSet;
|
||||
use regex::{Regex, RegexSet};
|
||||
use smithay::{
|
||||
desktop::WindowSurface,
|
||||
wayland::{compositor::with_states, shell::xdg::XdgToplevelSurfaceData},
|
||||
xwayland::xwm::WmWindowType,
|
||||
};
|
||||
use tracing::warn;
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
|
|
@ -62,21 +63,28 @@ pub struct 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 titles = Vec::new();
|
||||
|
||||
for app in &config.cosmic_conf.tiling_exceptions {
|
||||
for title in &app.titles {
|
||||
app_ids.push(app.appid.clone());
|
||||
titles.push(title.clone());
|
||||
for exception in &config.tiling_exceptions {
|
||||
if let Err(e) = Regex::new(&exception.appid) {
|
||||
warn!("Invalid regex for appid: {}, {}", exception.appid, e);
|
||||
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 {
|
||||
app_ids: RegexSet::new(app_ids)?,
|
||||
titles: RegexSet::new(titles)?,
|
||||
})
|
||||
Self {
|
||||
app_ids: RegexSet::new(app_ids).unwrap(),
|
||||
titles: RegexSet::new(titles).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::{
|
|||
sync::atomic::Ordering,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tracing::error;
|
||||
use wayland_backend::server::ClientId;
|
||||
|
||||
use crate::wayland::protocols::workspace::WorkspaceCapabilities;
|
||||
|
|
@ -1236,10 +1235,7 @@ impl Shell {
|
|||
pub fn new(config: &Config) -> Self {
|
||||
let theme = cosmic::theme::system_preference();
|
||||
|
||||
let tiling_exceptions = layout::TilingExceptions::new(config).unwrap_or_else(|e| {
|
||||
error!(?e, "Could not load tiling exceptions, using default");
|
||||
layout::TilingExceptions::default()
|
||||
});
|
||||
let tiling_exceptions = layout::TilingExceptions::new(config);
|
||||
|
||||
Shell {
|
||||
workspaces: Workspaces::new(config, theme.clone()),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue