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

This commit is contained in:
Kingtous committed 2023-02-07 16:20:37 +08:00
1 parent cab1fc719a
commit 7e5c5b50e5
5 files changed
+85 -4

No files matched your search

+18
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")