wayvrctl + panel-modify ipc
This commit is contained in:
85
Cargo.lock
generated
85
Cargo.lock
generated
@@ -557,7 +557,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d123397e75f904758fef490775a00b0ada545ab409cb0163d919799e5a30119b"
|
||||
dependencies = [
|
||||
"autocxx-engine",
|
||||
"env_logger",
|
||||
"env_logger 0.9.3",
|
||||
"indexmap 1.9.3",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
@@ -1750,6 +1750,16 @@ dependencies = [
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_filter"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2"
|
||||
dependencies = [
|
||||
"log",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.3"
|
||||
@@ -1763,6 +1773,19 @@ dependencies = [
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.11.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c863f0904021b108aa8b2f55046443e6b1ebde8fd4a15c399893aae4fa069f"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"env_filter",
|
||||
"jiff",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equator"
|
||||
version = "0.4.2"
|
||||
@@ -2954,6 +2977,30 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jiff"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49cce2b81f2098e7e3efc35bc2e0a6b7abec9d34128283d7a26fa8f32a6dbb35"
|
||||
dependencies = [
|
||||
"jiff-static",
|
||||
"log",
|
||||
"portable-atomic",
|
||||
"portable-atomic-util",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jiff-static"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "980af8b43c3ad5d8d349ace167ec8170839f753a42d233ba19e08afe1850fa69"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jni"
|
||||
version = "0.21.1"
|
||||
@@ -4271,6 +4318,21 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f59e70c4aef1e55797c2e8fd94a4f2a973fc972cfde0e0b05f683667b0cd39dd"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic-util"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507"
|
||||
dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.4"
|
||||
@@ -5047,6 +5109,12 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shell-words"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
@@ -6373,6 +6441,21 @@ dependencies = [
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wayvrctl"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"env_logger 0.11.8",
|
||||
"log",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shell-words",
|
||||
"tokio",
|
||||
"wayvr-ipc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.83"
|
||||
|
||||
@@ -17,18 +17,21 @@ members = [
|
||||
"wlx-overlay-s",
|
||||
"wlx-capture",
|
||||
"dash-frontend",
|
||||
"wayvr-ipc",
|
||||
"wayvr-ipc", "wayvrctl",
|
||||
]
|
||||
resolver = "3"
|
||||
|
||||
[workspace.dependencies]
|
||||
anyhow = "1.0.100"
|
||||
glam = { version = "0.30.9", features = ["mint", "serde"] }
|
||||
clap = { version = "4.5.53", features = ["derive"] }
|
||||
idmap = "0.2.2"
|
||||
idmap-derive = "0.2.22"
|
||||
log = "0.4.29"
|
||||
regex = "1.12.2"
|
||||
rust-embed = "8.9.0"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1.0.145"
|
||||
slotmap = "1.1.1"
|
||||
vulkano = { version = "0.35.2", default-features = false, features = [
|
||||
"macros",
|
||||
|
||||
@@ -7,11 +7,11 @@ edition = "2024"
|
||||
anyhow.workspace = true
|
||||
wgui = { path = "../wgui/" }
|
||||
glam = { workspace = true, features = ["mint", "serde"] }
|
||||
log = { workspace = true }
|
||||
rust-embed = { workspace = true }
|
||||
log.workspace = true
|
||||
rust-embed.workspace = true
|
||||
chrono = "0.4.42"
|
||||
gio = "0.21.5"
|
||||
gtk = "0.18.2"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0.145"
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
wlx-common = { path = "../wlx-common" }
|
||||
|
||||
@@ -6,7 +6,7 @@ edition = "2024"
|
||||
[dependencies]
|
||||
bytes = "1.9.0"
|
||||
smallvec = "1.13.2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde.workspace = true
|
||||
anyhow = "1.0.93"
|
||||
log = "0.4.22"
|
||||
|
||||
@@ -14,7 +14,7 @@ log = "0.4.22"
|
||||
interprocess = { version = "2.2.2", features = ["tokio"], optional = true }
|
||||
tokio = { version = "1.43.1", features = ["macros"], optional = true }
|
||||
tokio-util = { version = "0.7.13", optional = true }
|
||||
serde_json = "1.0.135"
|
||||
serde_json.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["client"]
|
||||
|
||||
@@ -486,6 +486,14 @@ impl WayVRClient {
|
||||
send_only!(client, &PacketClient::WlxHaptics(params));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn fn_wlx_modify_panel(
|
||||
client: WayVRClientMutex,
|
||||
params: packet_client::WlxModifyPanelParams,
|
||||
) -> anyhow::Result<()> {
|
||||
send_only!(client, &PacketClient::WlxModifyPanel(params));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WayVRClient {
|
||||
|
||||
@@ -49,7 +49,7 @@ pub struct WlxHapticsParams {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum WlxCustomCommand {
|
||||
pub enum WlxModifyPanelCommand {
|
||||
SetText(String),
|
||||
SetColor(String),
|
||||
SetSprite(String),
|
||||
@@ -58,10 +58,10 @@ pub enum WlxCustomCommand {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct WlxCustomParams {
|
||||
pub struct WlxModifyPanelParams {
|
||||
pub overlay: String,
|
||||
pub element: String,
|
||||
pub command: WlxCustomCommand,
|
||||
pub command: WlxModifyPanelCommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
@@ -84,5 +84,5 @@ pub enum PacketClient {
|
||||
WvrProcessTerminate(packet_server::WvrProcessHandle),
|
||||
WlxHaptics(WlxHapticsParams),
|
||||
WlxInputState(Serial),
|
||||
WlxCustom(WlxCustomParams),
|
||||
WlxModifyPanel(WlxModifyPanelParams),
|
||||
}
|
||||
|
||||
15
wayvrctl/Cargo.toml
Normal file
15
wayvrctl/Cargo.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "wayvrctl"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
log.workspace = true
|
||||
clap.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
env_logger = "0.11.8"
|
||||
tokio = "1.48.0"
|
||||
wayvr-ipc = { path = "../wayvr-ipc" }
|
||||
shell-words = "1.1.1"
|
||||
246
wayvrctl/src/helper.rs
Normal file
246
wayvrctl/src/helper.rs
Normal file
@@ -0,0 +1,246 @@
|
||||
use std::{collections::HashMap};
|
||||
|
||||
use anyhow::Context;
|
||||
use serde::Serialize;
|
||||
use wayvr_ipc::{client::{WayVRClient, WayVRClientMutex}, ipc, packet_client, packet_server};
|
||||
|
||||
pub struct WayVRClientState {
|
||||
pub wayvr_client: WayVRClientMutex,
|
||||
pub serial_generator: ipc::SerialGenerator,
|
||||
pub pretty_print: bool,
|
||||
}
|
||||
|
||||
fn handle_empty_result(result: anyhow::Result<()>) {
|
||||
if let Err(e) = result {
|
||||
log::error!("{e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_result<T: Serialize>(pretty_print: bool, result: anyhow::Result<T>) {
|
||||
match result {
|
||||
Ok(t) => {
|
||||
|
||||
let maybe_json = if pretty_print {
|
||||
serde_json::to_string_pretty(&t)
|
||||
} else {
|
||||
serde_json::to_string(&t)
|
||||
};
|
||||
|
||||
match maybe_json {
|
||||
Ok(json_string) => println!("{}", json_string),
|
||||
Err(e) => log::error!("Failed to serialize JSON: {e:?}")
|
||||
}
|
||||
}
|
||||
Err(e) => log::error!("{e:?}")
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn wvr_display_create(
|
||||
state: &mut WayVRClientState,
|
||||
width: u16,
|
||||
height: u16,
|
||||
name: String,
|
||||
scale: Option<f32>,
|
||||
attach_to: packet_client::AttachTo,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_display_create(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
packet_client::WvrDisplayCreateParams {
|
||||
width,
|
||||
height,
|
||||
name,
|
||||
scale,
|
||||
attach_to,
|
||||
},
|
||||
)
|
||||
.await.context("failed to create display")
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_display_list(
|
||||
state: &mut WayVRClientState,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_display_list(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
)
|
||||
.await.context("failed to fetch displays")
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_display_get(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrDisplayHandle,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_display_get(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
handle,
|
||||
)
|
||||
.await.context("failed to fetch display")
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_display_window_list(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrDisplayHandle,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_display_window_list(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
handle,
|
||||
)
|
||||
.await.context("failed to list window displays")
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_display_remove(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrDisplayHandle,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_display_remove(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
handle,
|
||||
)
|
||||
.await.context("failed to remove display")
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_display_set_visible(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrDisplayHandle,
|
||||
visible: bool,
|
||||
) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wvr_display_set_visible(state.wayvr_client.clone(), handle, visible).await.context("failed to set display visibility"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wvr_window_set_visible(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrWindowHandle,
|
||||
visible: bool,
|
||||
) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wvr_window_set_visible(state.wayvr_client.clone(), handle, visible).await.context("failed to set window visibility"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wvr_process_get(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrProcessHandle,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_process_get(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
handle,
|
||||
)
|
||||
.await.context("failed to get process"),
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn wvr_process_list(
|
||||
state: &mut WayVRClientState,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_process_list(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
)
|
||||
.await.context("failed to list processes"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wvr_process_terminate(
|
||||
state: &mut WayVRClientState,
|
||||
handle: packet_server::WvrProcessHandle,
|
||||
) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wvr_process_terminate(state.wayvr_client.clone(), handle).await.context("failed to terminate process"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wvr_process_launch(
|
||||
state: &mut WayVRClientState,
|
||||
exec: String,
|
||||
name: String,
|
||||
env: Vec<String>,
|
||||
target_display: packet_server::WvrDisplayHandle,
|
||||
args: String,
|
||||
userdata: HashMap<String, String>,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wvr_process_launch(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
packet_client::WvrProcessLaunchParams {
|
||||
env,
|
||||
exec,
|
||||
name,
|
||||
target_display,
|
||||
args,
|
||||
userdata,
|
||||
},
|
||||
)
|
||||
.await.context("failed to launch process"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_haptics(
|
||||
state: &mut WayVRClientState,
|
||||
intensity: f32,
|
||||
duration: f32,
|
||||
frequency: f32,
|
||||
) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wlx_haptics(
|
||||
state.wayvr_client.clone(),
|
||||
packet_client::WlxHapticsParams {
|
||||
intensity,
|
||||
duration,
|
||||
frequency,
|
||||
},
|
||||
)
|
||||
.await.context("failed to trigger haptics"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_panel_modify(
|
||||
state: &mut WayVRClientState,
|
||||
overlay: String,
|
||||
element: String,
|
||||
command: packet_client::WlxModifyPanelCommand,
|
||||
) {
|
||||
handle_empty_result(
|
||||
WayVRClient::fn_wlx_modify_panel(
|
||||
state.wayvr_client.clone(),
|
||||
packet_client::WlxModifyPanelParams {
|
||||
overlay,
|
||||
element,
|
||||
command,
|
||||
},
|
||||
)
|
||||
.await.context("failed to modify panel"),
|
||||
)
|
||||
}
|
||||
|
||||
pub async fn wlx_input_state(
|
||||
state: &mut WayVRClientState,
|
||||
) {
|
||||
handle_result(state.pretty_print,
|
||||
WayVRClient::fn_wlx_input_state(
|
||||
state.wayvr_client.clone(),
|
||||
state.serial_generator.increment_get(),
|
||||
)
|
||||
.await.context("failed to get input state"),
|
||||
)
|
||||
}
|
||||
|
||||
279
wayvrctl/src/main.rs
Normal file
279
wayvrctl/src/main.rs
Normal file
@@ -0,0 +1,279 @@
|
||||
use std::{collections::HashMap, process::{self, ExitCode}};
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use env_logger::Env;
|
||||
use wayvr_ipc::{client::WayVRClient, ipc, packet_client, };
|
||||
|
||||
use crate::helper::{wlx_haptics, wlx_input_state, wlx_panel_modify, wvr_display_create, wvr_display_get, wvr_display_list, wvr_display_remove, wvr_display_set_visible, wvr_display_window_list, wvr_process_get, wvr_process_launch, wvr_process_list, wvr_process_terminate, wvr_window_set_visible, WayVRClientState};
|
||||
|
||||
mod helper;
|
||||
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> ExitCode {
|
||||
env_logger::init_from_env(Env::default().default_filter_or("info"));
|
||||
let args = Args::parse();
|
||||
|
||||
let mut state = WayVRClientState {
|
||||
wayvr_client : WayVRClient::new(&format!("wayvrctl-{}", process::id())).await.inspect_err(|e| {
|
||||
log::error!("Failed to initialize WayVR connection: {e:?}");
|
||||
process::exit(1);
|
||||
}).unwrap(),
|
||||
serial_generator: ipc::SerialGenerator::new(),
|
||||
pretty_print: args.pretty,
|
||||
};
|
||||
|
||||
let maybe_err = if let Subcommands::Batch {fail_fast} = args.command {
|
||||
run_batch(&mut state, fail_fast).await
|
||||
} else {
|
||||
run_once(&mut state, args).await
|
||||
};
|
||||
|
||||
if let Err(e) = maybe_err{
|
||||
log::error!("{e:?}");
|
||||
return ExitCode::FAILURE;
|
||||
}
|
||||
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
async fn run_batch(state: &mut WayVRClientState, fail_fast: bool) -> anyhow::Result<()> {
|
||||
let stdin = std::io::stdin();
|
||||
|
||||
for (line_no, line) in stdin.lines().enumerate() {
|
||||
let line = line.context("error reading stdin")?;
|
||||
|
||||
if line.trim().is_empty() || line.trim_start().starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Err(e) = parse_run_line(state, &line).await.with_context(|| format!("error on line {}", line_no + 1)) {
|
||||
if fail_fast {
|
||||
return Err(e)
|
||||
} else {
|
||||
log::error!("{e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn parse_run_line(state: &mut WayVRClientState, line: &str) -> anyhow::Result<()> {
|
||||
let mut argv = shell_words::split(&line)
|
||||
.with_context(|| format!("parse error"))
|
||||
?;
|
||||
|
||||
// clap expects argv[0] to be the binary name
|
||||
argv.insert(0, env!("CARGO_PKG_NAME").to_string());
|
||||
|
||||
let args = Args::try_parse_from(argv).with_context(|| format!("invalid arguments"))?;
|
||||
run_once(state, args).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_once(state: &mut WayVRClientState, args: Args) -> anyhow::Result<()> {
|
||||
match args.command {
|
||||
Subcommands::Batch { .. } => {
|
||||
log::warn!("Ignoring recursive batch command");
|
||||
}
|
||||
Subcommands::InputState => {
|
||||
wlx_input_state(state).await;
|
||||
}
|
||||
Subcommands::DisplayCreate { width, height, name, scale } => {
|
||||
wvr_display_create(state, width, height, name, scale, packet_client::AttachTo::None).await;
|
||||
}
|
||||
Subcommands::DisplayList => {
|
||||
wvr_display_list(state).await;
|
||||
}
|
||||
Subcommands::DisplayGet { handle } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_display_get(state, handle).await;
|
||||
}
|
||||
Subcommands::DisplayWindowList { handle } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_display_window_list(state, handle).await;
|
||||
}
|
||||
Subcommands::DisplayRemove { handle } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_display_remove(state, handle).await;
|
||||
}
|
||||
Subcommands::DisplaySetVisible { handle, visible_0_or_1 } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_display_set_visible(state, handle, visible_0_or_1 != 0).await;
|
||||
}
|
||||
Subcommands::WindowSetVisible { handle, visible_0_or_1 } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_window_set_visible(state, handle, visible_0_or_1 != 0).await;
|
||||
}
|
||||
Subcommands::ProcessGet { handle } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_process_get(state, handle).await;
|
||||
}
|
||||
Subcommands::ProcessList => {
|
||||
wvr_process_list(state).await;
|
||||
}
|
||||
Subcommands::ProcessTerminate { handle } => {
|
||||
let handle = serde_json::from_str(&handle).context("Invalid handle")?;
|
||||
wvr_process_terminate(state, handle).await;
|
||||
}
|
||||
Subcommands::ProcessLaunch { exec, name, env, target_display, args } => {
|
||||
let handle = serde_json::from_str(&target_display).context("Invalid target_display")?;
|
||||
wvr_process_launch(state, exec, name, env, handle, args, HashMap::new()).await;
|
||||
}
|
||||
Subcommands::Haptics { intensity, duration, frequency } => {
|
||||
wlx_haptics(state, intensity, duration, frequency).await;
|
||||
}
|
||||
Subcommands::PanelModify { overlay, element, command } => {
|
||||
let command = match command {
|
||||
SubcommandPanelModify::SetText { text } => packet_client::WlxModifyPanelCommand::SetText(text),
|
||||
SubcommandPanelModify::SetColor { hex_color } => packet_client::WlxModifyPanelCommand::SetColor(hex_color),
|
||||
SubcommandPanelModify::SetSprite { absolute_path } => packet_client::WlxModifyPanelCommand::SetSprite(absolute_path),
|
||||
SubcommandPanelModify::SetVisible { visible_0_or_1 } => packet_client::WlxModifyPanelCommand::SetVisible(visible_0_or_1 != 0),
|
||||
SubcommandPanelModify::SetStickyState { sticky_state_0_or_1 } => packet_client::WlxModifyPanelCommand::SetStickyState(sticky_state_0_or_1 != 0),
|
||||
};
|
||||
|
||||
wlx_panel_modify(state, overlay, element, command).await;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// A command-line interface for WayVR IPC
|
||||
#[derive(clap::Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// The command to run
|
||||
#[command(subcommand)]
|
||||
command: Subcommands,
|
||||
|
||||
/// Pretty-print JSON output
|
||||
#[arg(short, long)]
|
||||
pretty: bool,
|
||||
}
|
||||
|
||||
#[derive(clap::Parser, Debug)]
|
||||
enum Subcommands {
|
||||
/// Read commands from stdout, one per line.
|
||||
Batch {
|
||||
/// Stop on the first error
|
||||
#[arg(short, long)]
|
||||
fail_fast: bool,
|
||||
},
|
||||
/// Get the positions of HMD & controllers
|
||||
InputState,
|
||||
/// Create a new WayVR display
|
||||
DisplayCreate{
|
||||
width: u16,
|
||||
height: u16,
|
||||
name: String,
|
||||
#[arg(short, long)]
|
||||
scale: Option<f32>,
|
||||
|
||||
//attach_to: packet_client::AttachTo,
|
||||
},
|
||||
/// List WayVR displays
|
||||
DisplayList,
|
||||
/// Retrieve information about a single WayVR display
|
||||
DisplayGet {
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
handle: String,
|
||||
},
|
||||
/// List windows attached to a WayVR display
|
||||
DisplayWindowList {
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
handle: String,
|
||||
},
|
||||
/// Delete a WayVR display
|
||||
DisplayRemove {
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
handle: String,
|
||||
},
|
||||
/// Change the visibility of a WayVR display
|
||||
DisplaySetVisible {
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
handle: String,
|
||||
visible_0_or_1: u8,
|
||||
},
|
||||
|
||||
// DisplaySetLayout skipped
|
||||
|
||||
/// Change the visibility of a window on a WayVR display
|
||||
WindowSetVisible {
|
||||
/// A JSON window handle returned by DisplayWindowList
|
||||
handle: String,
|
||||
visible_0_or_1: u8,
|
||||
},
|
||||
/// Retrieve information about a WayVR-managed process
|
||||
ProcessGet {
|
||||
/// A JSON process handle returned by ProcessList or ProcessLaunch
|
||||
handle: String,
|
||||
|
||||
},
|
||||
/// List all processes managed by WayVR
|
||||
ProcessList,
|
||||
/// Terminate a WayVR-managed process
|
||||
ProcessTerminate {
|
||||
/// A JSON process handle returned by ProcessList or ProcessLaunch
|
||||
handle: String,
|
||||
},
|
||||
/// Launch a new process inside WayVR
|
||||
ProcessLaunch {
|
||||
exec: String,
|
||||
name: String,
|
||||
env: Vec<String>,
|
||||
/// A display handle JSON returned by DisplayList or DisplayCreate
|
||||
target_display: String,
|
||||
args: String,
|
||||
},
|
||||
/// Trigger haptics on the user's controller
|
||||
Haptics {
|
||||
#[arg(short, long, default_value = "0.25")]
|
||||
intensity: f32,
|
||||
#[arg(short, long , default_value = "0.1")]
|
||||
duration: f32,
|
||||
#[arg(short, long, default_value = "0.1")]
|
||||
frequency: f32,
|
||||
},
|
||||
/// Apply a modification to a panel element
|
||||
PanelModify {
|
||||
/// The name of the overlay (XML file name without extension)
|
||||
overlay: String,
|
||||
/// The id of the element to modify, as set in the XML
|
||||
element: String,
|
||||
/// Command to execute
|
||||
#[command(subcommand)]
|
||||
command: SubcommandPanelModify,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(clap::Parser, Debug)]
|
||||
enum SubcommandPanelModify {
|
||||
/// Set the text of a <label> or <Button>
|
||||
SetText {
|
||||
/// Text that needs to be set
|
||||
text: String,
|
||||
},
|
||||
/// Set the color of a <rectangle> or <label> or monochrome <sprite>
|
||||
SetColor {
|
||||
/// Color in HTML hex format (#rrggbb or #rrggbbaa)
|
||||
hex_color: String,
|
||||
},
|
||||
/// Set the content of a sprite
|
||||
SetSprite {
|
||||
/// Absolute path to a svg, gif, png, jpeg or webp image.
|
||||
absolute_path: String,
|
||||
},
|
||||
/// Set the visibility of a <div>, <rectangle>, <label> or <sprite>
|
||||
SetVisible {
|
||||
visible_0_or_1: u8,
|
||||
},
|
||||
/// Set the sticky state of a <Button>. Intended for buttons without `sticky="1"`.
|
||||
SetStickyState {
|
||||
sticky_state_0_or_1: u8,
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
anyhow.workspace = true
|
||||
cosmic-text = "0.15.0"
|
||||
etagere = "0.2.15"
|
||||
glam = { workspace = true }
|
||||
glam.workspace = true
|
||||
image = { version = "0.25.9", default-features = false, features = [
|
||||
"gif",
|
||||
"jpeg",
|
||||
@@ -15,19 +15,19 @@ image = { version = "0.25.9", default-features = false, features = [
|
||||
"rayon",
|
||||
"webp",
|
||||
] }
|
||||
log = { workspace = true }
|
||||
log.workspace = true
|
||||
lru = "0.16.2"
|
||||
ouroboros = "0.18.5"
|
||||
parking_lot = "0.12.5"
|
||||
regex = { workspace = true }
|
||||
regex.workspace = true
|
||||
resvg = { version = "0.45.1", default-features = false }
|
||||
roxmltree = "0.21.1"
|
||||
rustc-hash = "2.1.1"
|
||||
serde_json = "1.0.145"
|
||||
slotmap = { workspace = true }
|
||||
serde_json.workspace = true
|
||||
slotmap.workspace = true
|
||||
smallvec = "1.15.1"
|
||||
taffy = "0.9.2"
|
||||
vulkano = { workspace = true }
|
||||
vulkano-shaders = { workspace = true }
|
||||
rust-embed = { workspace = true }
|
||||
vulkano.workspace = true
|
||||
vulkano-shaders.workspace = true
|
||||
rust-embed.workspace = true
|
||||
flate2 = "1.1.5"
|
||||
|
||||
@@ -5,7 +5,7 @@ edition = "2024"
|
||||
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.228", features = ["derive", "rc"] }
|
||||
serde = { workspace = true, features = ["rc"] }
|
||||
glam = { workspace = true }
|
||||
chrono = "0.4.42"
|
||||
idmap = { workspace = true, features = ["serde"] }
|
||||
|
||||
@@ -20,11 +20,16 @@ categories = ["games"]
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
log.workspace = true
|
||||
slotmap.workspace = true
|
||||
serde = { workspace = true, features = ["rc"] }
|
||||
serde_json.workspace = true
|
||||
|
||||
ash = "^0.38.0" # must match vulkano
|
||||
chrono = "0.4.42"
|
||||
chrono-tz = "0.10.4"
|
||||
clap = { version = "4.5.53", features = ["derive"] }
|
||||
config = "0.15.19"
|
||||
dbus = { version = "0.9.9" }
|
||||
futures = "0.3.31"
|
||||
@@ -35,7 +40,6 @@ input-linux = "0.7.1"
|
||||
json = { version = "0.12.4", optional = true }
|
||||
json5 = "1.3.0"
|
||||
libc = "0.2.178"
|
||||
log = { workspace = true }
|
||||
openxr = { git = "https://github.com/Ralith/openxrs", rev = "d0afdd3365bc1e14de28f6a3a21f457e788a702e", features = [
|
||||
"linked",
|
||||
"mint",
|
||||
@@ -51,10 +55,7 @@ rodio = { version = "0.21.1", default-features = false, features = [
|
||||
"hound",
|
||||
] }
|
||||
rosc = { version = "0.11.4", optional = true }
|
||||
serde = { version = "1.0.228", features = ["derive", "rc"] }
|
||||
serde_json = "1.0.145"
|
||||
serde_yaml = "0.9.34"
|
||||
slotmap = { workspace = true }
|
||||
smallvec = "1.15.1"
|
||||
strum = { version = "0.27.2", features = ["derive"] }
|
||||
sysinfo = { version = "0.37" }
|
||||
|
||||
@@ -55,7 +55,7 @@ pub enum PlayspaceTask {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OverlayCustomCommand {
|
||||
pub enum ModifyPanelCommand {
|
||||
SetText(String),
|
||||
SetColor(String),
|
||||
SetSprite(String),
|
||||
@@ -64,10 +64,10 @@ pub enum OverlayCustomCommand {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OverlayCustomTask {
|
||||
pub struct ModifyPanelTask {
|
||||
pub overlay: String,
|
||||
pub element: String,
|
||||
pub command: OverlayCustomCommand,
|
||||
pub command: ModifyPanelCommand,
|
||||
}
|
||||
|
||||
pub type ModifyOverlayTask = dyn FnOnce(&mut AppState, &mut OverlayWindowConfig) + Send;
|
||||
@@ -82,7 +82,7 @@ pub enum OverlayTask {
|
||||
CleanupMirrors,
|
||||
Modify(OverlaySelector, Box<ModifyOverlayTask>),
|
||||
Create(OverlaySelector, Box<CreateOverlayTask>),
|
||||
Custom(OverlayCustomTask),
|
||||
ModifyPanel(ModifyPanelTask),
|
||||
Drop(OverlaySelector),
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ pub enum WayVRSignal {
|
||||
BroadcastStateChanged(packet_server::WvrStateChanged),
|
||||
DropOverlay(crate::windowing::OverlayID),
|
||||
Haptics(super::input::Haptics),
|
||||
CustomTask(crate::backend::task::OverlayCustomTask),
|
||||
CustomTask(crate::backend::task::ModifyPanelTask),
|
||||
}
|
||||
|
||||
pub enum BlitMethod {
|
||||
|
||||
@@ -479,30 +479,33 @@ impl Connection {
|
||||
));
|
||||
}
|
||||
|
||||
fn handle_wlx_custom(params: &mut TickParams, custom_params: packet_client::WlxCustomParams) {
|
||||
use crate::backend::task::{OverlayCustomCommand, OverlayCustomTask};
|
||||
fn handle_wlx_panel(
|
||||
params: &mut TickParams,
|
||||
custom_params: packet_client::WlxModifyPanelParams,
|
||||
) {
|
||||
use crate::backend::task::{ModifyPanelCommand, ModifyPanelTask};
|
||||
|
||||
params
|
||||
.state
|
||||
.signals
|
||||
.send(super::WayVRSignal::CustomTask(OverlayCustomTask {
|
||||
.send(super::WayVRSignal::CustomTask(ModifyPanelTask {
|
||||
overlay: custom_params.overlay,
|
||||
element: custom_params.element,
|
||||
command: match custom_params.command {
|
||||
packet_client::WlxCustomCommand::SetText(text) => {
|
||||
OverlayCustomCommand::SetText(text)
|
||||
packet_client::WlxModifyPanelCommand::SetText(text) => {
|
||||
ModifyPanelCommand::SetText(text)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetSprite(sprite) => {
|
||||
OverlayCustomCommand::SetSprite(sprite)
|
||||
packet_client::WlxModifyPanelCommand::SetSprite(sprite) => {
|
||||
ModifyPanelCommand::SetSprite(sprite)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetStickyState(sticky) => {
|
||||
OverlayCustomCommand::SetStickyState(sticky)
|
||||
packet_client::WlxModifyPanelCommand::SetStickyState(sticky) => {
|
||||
ModifyPanelCommand::SetStickyState(sticky)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetVisible(visible) => {
|
||||
OverlayCustomCommand::SetVisible(visible)
|
||||
packet_client::WlxModifyPanelCommand::SetVisible(visible) => {
|
||||
ModifyPanelCommand::SetVisible(visible)
|
||||
}
|
||||
packet_client::WlxCustomCommand::SetColor(color) => {
|
||||
OverlayCustomCommand::SetColor(color)
|
||||
packet_client::WlxModifyPanelCommand::SetColor(color) => {
|
||||
ModifyPanelCommand::SetColor(color)
|
||||
}
|
||||
},
|
||||
}));
|
||||
@@ -560,8 +563,8 @@ impl Connection {
|
||||
PacketClient::WlxHaptics(haptics_params) => {
|
||||
Self::handle_wlx_haptics(params, haptics_params);
|
||||
}
|
||||
PacketClient::WlxCustom(custom_params) => {
|
||||
Self::handle_wlx_custom(params, custom_params);
|
||||
PacketClient::WlxModifyPanel(custom_params) => {
|
||||
Self::handle_wlx_panel(params, custom_params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ use wgui::{
|
||||
use wlx_common::windowing::OverlayWindowState;
|
||||
|
||||
use crate::{
|
||||
backend::task::OverlayCustomCommand,
|
||||
backend::task::ModifyPanelCommand,
|
||||
gui::{
|
||||
panel::{GuiPanel, NewGuiPanelParams},
|
||||
timer::GuiTimer,
|
||||
@@ -86,7 +86,7 @@ fn apply_custom_command(
|
||||
panel: &mut GuiPanel<CustomPanelState>,
|
||||
app: &mut AppState,
|
||||
element: &str,
|
||||
command: &OverlayCustomCommand,
|
||||
command: &ModifyPanelCommand,
|
||||
) -> anyhow::Result<()> {
|
||||
let mut alterables = EventAlterables::default();
|
||||
let mut com = CallbackDataCommon {
|
||||
@@ -95,7 +95,7 @@ fn apply_custom_command(
|
||||
};
|
||||
|
||||
match command {
|
||||
OverlayCustomCommand::SetText(text) => {
|
||||
ModifyPanelCommand::SetText(text) => {
|
||||
if let Ok(mut label) = panel
|
||||
.parser_state
|
||||
.fetch_widget_as::<WidgetLabel>(&panel.layout.state, element)
|
||||
@@ -110,7 +110,7 @@ fn apply_custom_command(
|
||||
anyhow::bail!("No <label> or <Button> with such id.");
|
||||
}
|
||||
}
|
||||
OverlayCustomCommand::SetSprite(path) => {
|
||||
ModifyPanelCommand::SetSprite(path) => {
|
||||
let mut widget = panel
|
||||
.parser_state
|
||||
.fetch_widget_as::<WidgetSprite>(&panel.layout.state, element)
|
||||
@@ -130,7 +130,7 @@ fn apply_custom_command(
|
||||
widget.set_content(&mut com, Some(data));
|
||||
}
|
||||
}
|
||||
OverlayCustomCommand::SetColor(color) => {
|
||||
ModifyPanelCommand::SetColor(color) => {
|
||||
let color = parse_color_hex(&color)
|
||||
.context("Invalid color format, must be a html hex color!")?;
|
||||
|
||||
@@ -151,7 +151,7 @@ fn apply_custom_command(
|
||||
anyhow::bail!("No <rectangle> or <label> or <sprite> with such id.");
|
||||
}
|
||||
}
|
||||
OverlayCustomCommand::SetVisible(visible) => {
|
||||
ModifyPanelCommand::SetVisible(visible) => {
|
||||
let wid = panel
|
||||
.parser_state
|
||||
.get_widget_id(&element)
|
||||
@@ -166,7 +166,7 @@ fn apply_custom_command(
|
||||
com.alterables
|
||||
.set_style(wid, wgui::event::StyleSetRequest::Display(display));
|
||||
}
|
||||
OverlayCustomCommand::SetStickyState(sticky_down) => {
|
||||
ModifyPanelCommand::SetStickyState(sticky_down) => {
|
||||
let button = panel
|
||||
.parser_state
|
||||
.fetch_component_as::<ComponentButton>(element)
|
||||
|
||||
@@ -463,7 +463,7 @@ where
|
||||
}
|
||||
wayvr::WayVRSignal::CustomTask(custom_task) => {
|
||||
app.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::Custom(custom_task)));
|
||||
.enqueue(TaskType::Overlay(OverlayTask::ModifyPanel(custom_task)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use wlx_common::{
|
||||
use crate::{
|
||||
backend::{
|
||||
input::{HoverResult, PointerHit},
|
||||
task::OverlayCustomCommand,
|
||||
task::ModifyPanelCommand,
|
||||
},
|
||||
graphics::{ExtentExt, RenderResult},
|
||||
state::AppState,
|
||||
@@ -128,7 +128,7 @@ pub enum OverlayEventData {
|
||||
},
|
||||
CustomCommand {
|
||||
element: String,
|
||||
command: OverlayCustomCommand,
|
||||
command: ModifyPanelCommand,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ where
|
||||
self.dropped_overlays.push_back(o);
|
||||
}
|
||||
}
|
||||
OverlayTask::Custom(task) => {
|
||||
OverlayTask::ModifyPanel(task) => {
|
||||
if let Some(oid) = self.lookup(&task.overlay)
|
||||
&& let Some(o) = self.mut_by_id(oid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user