diff --git a/CHANGELOG.md b/CHANGELOG.md index c936a95..db767e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.1.0] - 2017-11-13 +### Added +- Muting can be disabled by passing `-m false`. + ## [1.0.0] - 2017-11-11 ### Added - Dump command to show or save current configuration. @@ -14,6 +18,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Previous functionality for switching the output device has changed significantly. `sbz-switch --speakers 3003 --volume 60` becomes `sbz-switch set -i "Processing Control" SpeakerConfig 12291 --volume 60` (3003 was a hex value and 12291 is decimal), however it seems `-i "Device Control" SelectOutput 1` is a better way of doing the same thing. See README.md for more information about the new syntax. -## [0.1.0] - 2017-10-30 +## 0.1.0 - 2017-10-30 ### Added - Command to switch speaker configuration and adjust volume. + +[Unreleased]: https://github.com/mdonoughe/sbz-switch/compare/v1.1.0...HEAD +[1.1.0]: https://github.com/mdonoughe/sbz-switch/compare/v1.0.0...v1.1.0 +[1.0.0]: https://github.com/mdonoughe/sbz-switch/compare/v0.1.0...v1.0.0 diff --git a/Cargo.lock b/Cargo.lock index 25e9eb2..6e7e40e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,7 +205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "sbz-switch" -version = "1.0.0" +version = "1.1.0" dependencies = [ "clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)", "ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 555e26c..b0662fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sbz-switch" -version = "1.0.0" +version = "1.1.0" authors = ["Matthew Donoughe "] description = "Utility for changing Sound Blaster parameters on Windows" repository = "https://github.com/mdonoughe/sbz-switch/" diff --git a/README.md b/README.md index 24b1b6a..d62bf61 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,41 @@ This may have bugs. Use at your own risk, especially if you have configured your ## Usage +``` +USAGE: + sbz-switch.exe [SUBCOMMAND] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +SUBCOMMANDS: + apply applies a saved configuration + dump prints out the current configuration + help Prints this message or the help of the given subcommand(s) + set sets specific parameters +``` + ### Set > Set a small number of parameters +``` +USAGE: + sbz-switch.exe set [OPTIONS] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + -b Sets a boolean value + -f Sets a floating-point value + -i Sets an integer value + -m Temporarily mutes while changing parameters [default: true] + -v, --volume Sets the volume, in percent +``` + Switch to speakers at 60% volume with effects turned on: sbz-switch set -i "Device Control" SelectOutput 1 -b EfxMasterControl "THXEfx Master OnOff" true -v 60 @@ -36,6 +67,18 @@ Switch to headphones at 10% volume with effects turned off: > See or save the current parameters +``` +USAGE: + sbz-switch.exe dump [OPTIONS] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + -o, --output Saves the current settings to a file +``` + See the current settings: sbz-switch dump @@ -48,6 +91,19 @@ Save the current settings to headphones.toml: > Set many parameters at once +``` +USAGE: + sbz-switch.exe apply [OPTIONS] + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +OPTIONS: + -f Reads the settings from a file instead of stdin + -m Temporarily mutes while changing parameters [default: true] +``` + Apply the previously saved headphones.toml file: sbz-switch apply -f headphones.toml diff --git a/src/lib.rs b/src/lib.rs index ac3fe44..01d4d12 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,14 +122,14 @@ pub fn dump(logger: &Logger) -> Result> { Ok(output) } -pub fn set(logger: &Logger, configuration: &Configuration) -> Result<(), Box> { +pub fn set(logger: &Logger, configuration: &Configuration, mute: bool) -> Result<(), Box> { let endpoint = get_default_endpoint(logger)?; - let premuted = endpoint.get_mute()?; - if !premuted { + let mute_unmute = mute && !endpoint.get_mute()?; + if mute_unmute { endpoint.set_mute(true)?; } let result = set_internal(logger, configuration, &endpoint); - if !premuted { + if mute_unmute { endpoint.set_mute(false)?; } diff --git a/src/main.rs b/src/main.rs index 6ea9c14..90d9fb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +#[macro_use] extern crate clap; #[macro_use] extern crate slog; @@ -52,6 +53,14 @@ fn main() { .value_name("FILE") .help("Reads the settings from a file instead of stdin") .takes_value(true), + ) + .arg( + Arg::with_name("mute") + .short("m") + .value_name("true|false") + .default_value("true") + .help("Temporarily mutes while changing parameters") + .takes_value(true), ), ) .subcommand( @@ -91,6 +100,14 @@ fn main() { .value_name("VOLUME") .help("Sets the volume, in percent") .takes_value(true), + ) + .arg( + Arg::with_name("mute") + .short("m") + .value_name("true|false") + .default_value("true") + .help("Temporarily mutes while changing parameters") + .takes_value(true), ), ) .get_matches(); @@ -142,7 +159,8 @@ fn apply(logger: &Logger, matches: &ArgMatches) -> Result<(), Box> { let configuration: Configuration = toml::from_str(&text)?; mem::drop(text); - sbz_switch::set(logger, &configuration) + let mute = value_t!(matches, "mute", bool)?; + sbz_switch::set(logger, &configuration, mute) } struct Collator { @@ -235,5 +253,7 @@ fn set(logger: &Logger, matches: &ArgMatches) -> Result<(), Box> { }), creative: Some(creative_table), }; - sbz_switch::set(logger, &configuration) + + let mute = value_t!(matches, "mute", bool)?; + sbz_switch::set(logger, &configuration, mute) }