Keep Muninn Bluetooth hosts connectable for Move swaps

This commit is contained in:
Meta Vens 2026-06-17 01:06:04 +01:00
commit a0c62e8d07

View file

@ -313,6 +313,10 @@ fn claim_move_host_if_due(options: &Options, last_attempt_at: &mut Option<Instan
}
*last_attempt_at = Some(Instant::now());
if let Err(error) = prepare_move_bluetooth_host_for_claim() {
eprintln!("Muninn could not prepare Bluetooth host for USB PS Move claim: {error:#}");
}
let Some(host) = move_host_address_for_claim(options) else {
return;
};
@ -321,6 +325,27 @@ fn claim_move_host_if_due(options: &Options, last_attempt_at: &mut Option<Instan
}
}
#[cfg(unix)]
fn prepare_move_bluetooth_host_for_claim() -> Result<()> {
let output = Command::new("bluetoothctl")
.args(["pairable", "on"])
.output()
.context("bluetoothctl pairable on could not run")?;
if output.status.success() {
return Ok(());
}
let stderr = String::from_utf8_lossy(&output.stderr);
Err(anyhow!(
"bluetoothctl pairable on failed: {}",
stderr.trim()
))
}
#[cfg(not(unix))]
fn prepare_move_bluetooth_host_for_claim() -> Result<()> {
Ok(())
}
fn move_host_address_for_claim(options: &Options) -> Option<String> {
if let Some(host) = options.move_host_address.as_deref() {
if !host.trim().is_empty() {