feat(cli): add toggle-transparency cmd

This commit is contained in:
LGUG2Z
2024-07-17 17:25:22 -07:00
parent 6ea71834a1
commit 0f9c23b6f4
3 changed files with 10 additions and 0 deletions
+1
View File
@@ -150,6 +150,7 @@ pub enum SocketMessage {
BorderOffset(i32), BorderOffset(i32),
BorderImplementation(BorderImplementation), BorderImplementation(BorderImplementation),
Transparency(bool), Transparency(bool),
ToggleTransparency,
TransparencyAlpha(u8), TransparencyAlpha(u8),
InvisibleBorders(Rect), InvisibleBorders(Rect),
StackbarMode(StackbarMode), StackbarMode(StackbarMode),
+4
View File
@@ -1339,6 +1339,10 @@ impl WindowManager {
SocketMessage::AnimationStyle(style) => { SocketMessage::AnimationStyle(style) => {
*ANIMATION_STYLE.lock() = style; *ANIMATION_STYLE.lock() = style;
} }
SocketMessage::ToggleTransparency => {
let current = transparency_manager::TRANSPARENCY_ENABLED.load(Ordering::SeqCst);
transparency_manager::TRANSPARENCY_ENABLED.store(!current, Ordering::SeqCst);
}
SocketMessage::Transparency(enable) => { SocketMessage::Transparency(enable) => {
transparency_manager::TRANSPARENCY_ENABLED.store(enable, Ordering::SeqCst); transparency_manager::TRANSPARENCY_ENABLED.store(enable, Ordering::SeqCst);
} }
+5
View File
@@ -1249,6 +1249,8 @@ enum SubCommand {
/// Set the alpha value for unfocused window transparency /// Set the alpha value for unfocused window transparency
#[clap(arg_required_else_help = true)] #[clap(arg_required_else_help = true)]
TransparencyAlpha(TransparencyAlpha), TransparencyAlpha(TransparencyAlpha),
/// Toggle transparency for unfocused windows
ToggleTransparency,
/// Enable or disable the window move animation /// Enable or disable the window move animation
#[clap(arg_required_else_help = true)] #[clap(arg_required_else_help = true)]
Animation(Animation), Animation(Animation),
@@ -2328,6 +2330,9 @@ Stop-Process -Name:komorebi -ErrorAction SilentlyContinue
SubCommand::TransparencyAlpha(arg) => { SubCommand::TransparencyAlpha(arg) => {
send_message(&SocketMessage::TransparencyAlpha(arg.alpha))?; send_message(&SocketMessage::TransparencyAlpha(arg.alpha))?;
} }
SubCommand::ToggleTransparency => {
send_message(&SocketMessage::ToggleTransparency)?;
}
SubCommand::Animation(arg) => { SubCommand::Animation(arg) => {
send_message(&SocketMessage::Animation(arg.boolean_state.into()))?; send_message(&SocketMessage::Animation(arg.boolean_state.into()))?;
} }