paswitch-rs 0.3.17

List and swap to pulse sinks by name
use anyhow::{anyhow, Context, Result};
use std::process::Command;

use crate::commands::Type;

pub fn set_source(source: String) -> Result<()> {
    let output = Command::new(Type::Paswitch.to_string())
        .arg(&source)
        .output()
        .context("Failed to execute paswitch - invalid sink may have been supplied")?;

    if !output.status.success() {
        return Err(anyhow!("Paswitch failed to set source"));
    }

    println!("Set pulse output to id: {}", source);

    Ok(())
}