diff --git a/src/udev/mod.rs b/src/udev/mod.rs index e58b7506..15c85cc1 100644 --- a/src/udev/mod.rs +++ b/src/udev/mod.rs @@ -6,7 +6,11 @@ pub mod device_test; pub mod device; -use std::{error::Error, fs, path::PathBuf}; +use std::{ + error::Error, + fs, + path::{Path, PathBuf}, +}; use tokio::process::Command; use udev::Enumerator; @@ -46,16 +50,21 @@ pub async fn hide_device(path: &str, flags: &[HideFlag]) -> Result<(), Box Result<(), Box> { fs::remove_file(path)?; } + if !Path::new("/dev/inputplumber/sources").is_dir() { + reload_all().await?; + return Ok(()); + } + // Move all devices back let entries = fs::read_dir("/dev/inputplumber/sources")?; for entry in entries {