inputs websocket

This commit is contained in:
2025-02-09 00:08:13 +01:00
parent f805c7ecd3
commit 33593c8175

View File

@@ -362,6 +362,11 @@ pub enum WSCommand {
SwayCloseWorkspace { workspace: String }, SwayCloseWorkspace { workspace: String },
SwayChangeWorkspace { workspace: String }, SwayChangeWorkspace { workspace: String },
SwayGetWorkspaces, SwayGetWorkspaces,
// New input commands
InputKeys { keys: String },
MouseMove { x: i32, y: i32 },
MouseScroll { x: i32, y: i32 },
MouseClick { button: String },
} }
async fn handle_message( async fn handle_message(
@@ -472,5 +477,33 @@ async fn handle_message(
let workspaces = base::sway_get_workspace_names().await?; let workspaces = base::sway_get_workspace_names().await?;
Ok(Some(json!(workspaces))) Ok(Some(json!(workspaces)))
} }
WSCommand::InputKeys { keys } => {
base::input(keys)
.await
.map(|_| json!({}))
.map_err(anyhow::Error::new)?;
Ok(None)
}
WSCommand::MouseMove { x, y } => {
base::mouse_move(x, y)
.await
.map(|_| json!({}))
.map_err(anyhow::Error::new)?;
Ok(None)
}
WSCommand::MouseScroll { x, y } => {
base::mouse_scroll(x, y)
.await
.map(|_| json!({}))
.map_err(anyhow::Error::new)?;
Ok(None)
}
WSCommand::MouseClick { button } => {
base::mouse_click(button)
.await
.map(|_| json!({}))
.map_err(anyhow::Error::new)?;
Ok(None)
}
} }
} }