fix(sound): use pactl for setting default sinks and sources
This commit is contained in:
parent
a195885300
commit
67a5a9852c
1 changed files with 30 additions and 10 deletions
|
|
@ -435,16 +435,28 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::SinkChanged(pos) => {
|
Message::SinkChanged(pos) => {
|
||||||
if let Some(&node_id) = self.sink_ids.get(pos) {
|
if let Some(node_id) = self.sink_ids.get(pos) {
|
||||||
self.active_sink = Some(pos);
|
for card in self.devices.values() {
|
||||||
wpctl_set_default(node_id);
|
for (nid, device) in &card.devices {
|
||||||
|
if node_id == nid {
|
||||||
|
self.active_sink = Some(pos);
|
||||||
|
pactl_set_default_sink(device.identifier.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Message::SourceChanged(pos) => {
|
Message::SourceChanged(pos) => {
|
||||||
if let Some(&node_id) = self.source_ids.get(pos) {
|
if let Some(node_id) = self.source_ids.get(pos) {
|
||||||
self.active_source = Some(pos);
|
for card in self.devices.values() {
|
||||||
wpctl_set_default(node_id);
|
for (nid, device) in &card.devices {
|
||||||
|
if node_id == nid {
|
||||||
|
self.active_source = Some(pos);
|
||||||
|
pactl_set_default_source(device.identifier.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -660,11 +672,19 @@ fn pactl_set_card_profile(id: String, profile: String) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wpctl_set_default(id: u32) {
|
fn pactl_set_default_sink(id: String) {
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
let default = id.to_string();
|
_ = tokio::process::Command::new("pactl")
|
||||||
_ = tokio::process::Command::new("wpctl")
|
.args(&["set-default-sink", id.as_str()])
|
||||||
.args(&["set-default", default.as_str()])
|
.status()
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pactl_set_default_source(id: String) {
|
||||||
|
tokio::task::spawn(async move {
|
||||||
|
_ = tokio::process::Command::new("pactl")
|
||||||
|
.args(&["set-default-source", id.as_str()])
|
||||||
.status()
|
.status()
|
||||||
.await;
|
.await;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue