mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-20 07:31:39 +01:00
feat(cli): implement border-related cmds
This commit implements the various border-related SocketMessage variants and the komorebic commands to send them.
This commit is contained in:
1 parent
0cbf02b604
commit
8950a32bbb
4 files changed
+109
-22
No files matched your search
@@ -6,6 +6,7 @@ pub use komorebi::core::OperationBehaviour;
|
||||
pub use komorebi::core::Sizing;
|
||||
pub use komorebi::core::SocketMessage;
|
||||
pub use komorebi::core::StateQuery;
|
||||
pub use komorebi::core::WindowKind;
|
||||
pub use komorebi::core::arrangement::Axis;
|
||||
pub use komorebi::core::asc::ApplicationSpecificConfiguration;
|
||||
pub use komorebi::core::cycle_direction::CycleDirection;
|
||||
|
||||
@@ -366,14 +366,14 @@ pub enum SocketMessage {
|
||||
// AnimationDuration(u64, Option<AnimationPrefix>),
|
||||
// AnimationFps(u64),
|
||||
// AnimationStyle(AnimationStyle, Option<AnimationPrefix>),
|
||||
// #[serde(alias = "ActiveWindowBorder")]
|
||||
// Border(bool),
|
||||
// #[serde(alias = "ActiveWindowBorderColour")]
|
||||
// BorderColour(WindowKind, u32, u32, u32),
|
||||
#[serde(alias = "ActiveWindowBorder")]
|
||||
Border(bool),
|
||||
#[serde(alias = "ActiveWindowBorderColour")]
|
||||
BorderColour(WindowKind, u32, u32, u32),
|
||||
// #[serde(alias = "ActiveWindowBorderStyle")]
|
||||
// BorderStyle(BorderStyle),
|
||||
// BorderWidth(i32),
|
||||
// BorderOffset(i32),
|
||||
BorderWidth(i32),
|
||||
BorderOffset(i32),
|
||||
// BorderImplementation(BorderImplementation),
|
||||
// Transparency(bool),
|
||||
// ToggleTransparency,
|
||||
|
||||
@@ -19,6 +19,7 @@ use crate::core::MoveBehaviour;
|
||||
use crate::core::SocketMessage;
|
||||
use crate::core::StateQuery;
|
||||
use crate::core::WindowContainerBehaviour;
|
||||
use crate::core::WindowKind;
|
||||
use crate::core::arrangement::Axis;
|
||||
use crate::core::config_generation::IdWithIdentifier;
|
||||
use crate::core::config_generation::MatchingRule;
|
||||
@@ -48,6 +49,7 @@ use crate::workspace::WorkspaceWindowLocation;
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::Context;
|
||||
use color_eyre::eyre::OptionExt;
|
||||
use komorebi_themes::colour::Rgb;
|
||||
use objc2_core_foundation::CFDictionary;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashMap;
|
||||
@@ -59,6 +61,7 @@ use std::num::NonZeroUsize;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::time::Duration;
|
||||
|
||||
#[tracing::instrument]
|
||||
@@ -1670,6 +1673,41 @@ impl WindowManager {
|
||||
*self = wm;
|
||||
}
|
||||
}
|
||||
SocketMessage::Border(enable) => {
|
||||
border_manager::BORDER_ENABLED.store(enable, Ordering::SeqCst);
|
||||
if !enable {
|
||||
border_manager::destroy_all_borders()?;
|
||||
}
|
||||
}
|
||||
SocketMessage::BorderColour(kind, r, g, b) => match kind {
|
||||
WindowKind::Single => {
|
||||
border_manager::FOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Stack => {
|
||||
border_manager::STACK.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Monocle => {
|
||||
border_manager::MONOCLE.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Unfocused => {
|
||||
border_manager::UNFOCUSED.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::UnfocusedLocked => {
|
||||
border_manager::UNFOCUSED_LOCKED
|
||||
.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
WindowKind::Floating => {
|
||||
border_manager::FLOATING.store(Rgb::new(r, g, b).into(), Ordering::SeqCst);
|
||||
}
|
||||
},
|
||||
SocketMessage::BorderWidth(width) => {
|
||||
border_manager::BORDER_WIDTH.store(width, Ordering::SeqCst);
|
||||
border_manager::destroy_all_borders()?;
|
||||
}
|
||||
SocketMessage::BorderOffset(offset) => {
|
||||
border_manager::BORDER_OFFSET.store(offset, Ordering::SeqCst);
|
||||
border_manager::destroy_all_borders()?;
|
||||
}
|
||||
}
|
||||
|
||||
self.update_known_window_ids();
|
||||
|
||||
+64
-16
@@ -18,6 +18,7 @@ use komorebi_client::Rect;
|
||||
use komorebi_client::Sizing;
|
||||
use komorebi_client::SocketMessage;
|
||||
use komorebi_client::StateQuery;
|
||||
use komorebi_client::WindowKind;
|
||||
use komorebi_client::replace_env_in_path;
|
||||
use komorebi_client::send_message;
|
||||
use komorebi_client::send_query;
|
||||
@@ -610,6 +611,36 @@ struct ScrollingLayoutColumns {
|
||||
count: NonZeroUsize,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Border {
|
||||
#[clap(value_enum)]
|
||||
boolean_state: BooleanState,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct BorderColour {
|
||||
#[clap(value_enum, short, long, default_value = "single")]
|
||||
window_kind: WindowKind,
|
||||
/// Red
|
||||
r: u32,
|
||||
/// Green
|
||||
g: u32,
|
||||
/// Blue
|
||||
b: u32,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct BorderWidth {
|
||||
/// Desired width of the window border
|
||||
width: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
struct BorderOffset {
|
||||
/// Desired offset of the window border
|
||||
offset: i32,
|
||||
}
|
||||
|
||||
#[derive(Parser)]
|
||||
#[clap(author, about, version = build::CLAP_LONG_VERSION)]
|
||||
struct Opts {
|
||||
@@ -1047,22 +1078,22 @@ enum SubCommand {
|
||||
// #[clap(hide = true)]
|
||||
// #[clap(alias = "identify-border-overflow")]
|
||||
// IdentifyBorderOverflowApplication(IdentifyBorderOverflowApplication),
|
||||
// /// Enable or disable borders
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
// #[clap(alias = "active-window-border")]
|
||||
// Border(Border),
|
||||
// /// Set the colour for a window border kind
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
// #[clap(alias = "active-window-border-colour")]
|
||||
// BorderColour(BorderColour),
|
||||
// /// Set the border width
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
// #[clap(alias = "active-window-border-width")]
|
||||
// BorderWidth(BorderWidth),
|
||||
// /// Set the border offset
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
// #[clap(alias = "active-window-border-offset")]
|
||||
// BorderOffset(BorderOffset),
|
||||
/// Enable or disable borders
|
||||
#[clap(arg_required_else_help = true)]
|
||||
#[clap(alias = "active-window-border")]
|
||||
Border(Border),
|
||||
/// Set the colour for a window border kind
|
||||
#[clap(arg_required_else_help = true)]
|
||||
#[clap(alias = "active-window-border-colour")]
|
||||
BorderColour(BorderColour),
|
||||
/// Set the border width
|
||||
#[clap(arg_required_else_help = true)]
|
||||
#[clap(alias = "active-window-border-width")]
|
||||
BorderWidth(BorderWidth),
|
||||
/// Set the border offset
|
||||
#[clap(arg_required_else_help = true)]
|
||||
#[clap(alias = "active-window-border-offset")]
|
||||
BorderOffset(BorderOffset),
|
||||
// /// Set the border style
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
// BorderStyle(BorderStyle),
|
||||
@@ -2062,6 +2093,23 @@ fn main() -> eyre::Result<()> {
|
||||
SubCommand::ReplaceConfiguration(arg) => {
|
||||
send_message(&SocketMessage::ReplaceConfiguration(arg.path))?;
|
||||
}
|
||||
SubCommand::Border(arg) => {
|
||||
send_message(&SocketMessage::Border(arg.boolean_state.into()))?;
|
||||
}
|
||||
SubCommand::BorderColour(arg) => {
|
||||
send_message(&SocketMessage::BorderColour(
|
||||
arg.window_kind,
|
||||
arg.r,
|
||||
arg.g,
|
||||
arg.b,
|
||||
))?;
|
||||
}
|
||||
SubCommand::BorderWidth(arg) => {
|
||||
send_message(&SocketMessage::BorderWidth(arg.width))?;
|
||||
}
|
||||
SubCommand::BorderOffset(arg) => {
|
||||
send_message(&SocketMessage::BorderOffset(arg.offset))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in new issue
Block a user