feat: set to default input device when in dual-way

This commit is contained in:
Kingtous
2023-01-31 10:01:31 +08:00
parent cab1fc719a
commit 7e5c5b50e5
5 changed files with 85 additions and 4 deletions

View File

@@ -534,6 +534,24 @@ pub fn get_pa_sources() -> Vec<(String, String)> {
out
}
pub fn get_default_pa_source() -> Option<(String, String)> {
use pulsectl::controllers::*;
match SourceController::create() {
Ok(mut handler) => {
if let Ok(dev) = handler.get_default_device() {
return Some((
dev.name.unwrap_or("".to_owned()),
dev.description.unwrap_or("".to_owned()),
));
}
}
Err(err) => {
log::error!("Failed to get_pa_source: {:?}", err);
}
}
None
}
pub fn lock_screen() {
std::process::Command::new("xdg-screensaver")
.arg("lock")