-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from jamesmcm/pulseaudio
Add PulseAudio support
- Loading branch information
Showing
4 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "vopono" | ||
description = "Launch applications via VPN tunnels using temporary network namespaces" | ||
version = "0.5.3" | ||
version = "0.6.0" | ||
authors = ["James McMurray <[email protected]>"] | ||
edition = "2018" | ||
license = "GPL-3.0-or-later" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use anyhow::anyhow; | ||
use log::debug; | ||
use regex::Regex; | ||
use std::process::Command; | ||
|
||
pub fn get_pulseaudio_server() -> anyhow::Result<String> { | ||
let output = Command::new("pactl").args(&["info"]).output()?.stdout; | ||
let re = Regex::new(r"Server String: ([^\n]+)").unwrap(); | ||
let output = std::str::from_utf8(&output)?; | ||
|
||
let caps = re.captures(output); | ||
if caps.is_none() { | ||
return Err(anyhow!("Could not parse pactl output!")); | ||
} | ||
let caps = caps.unwrap().get(1); | ||
if caps.is_none() { | ||
return Err(anyhow!("Could not parse pactl output!")); | ||
} | ||
|
||
let out = caps.unwrap().as_str().to_string(); | ||
debug!("Setting PULSE_SERVER to {}", out); | ||
Ok(out) | ||
} |