Skip to content

Commit

Permalink
Add save screenshot command
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen-Samseth authored and grigio committed Apr 11, 2024
1 parent 9224051 commit 3037a96
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::{Parser, Subcommand};
use std::path::PathBuf;
use std::str::FromStr;
use url::Url;

Expand Down Expand Up @@ -119,6 +120,18 @@ pub enum Commands {
#[clap(subcommand)]
Recording(Recording),

SaveScreenshot {
source: String,
format: String,
file_path: PathBuf,
#[clap(long)]
width: Option<u32>,
#[clap(long)]
height: Option<u32>,
#[clap(long)]
compression_quality: Option<i32>,
},

ToggleMute {
device: String,
},
Expand Down
21 changes: 21 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use clap::Parser;
use obws::{requests::filters::SetEnabled as SetEnabledFilter, Client};
use obws::requests::scene_items::SetEnabled as SetEnabledItem;
use obws::requests::scene_items::Id as IdItem;
use obws::requests::sources::SaveScreenshot;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -77,6 +78,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}

Commands::SaveScreenshot {
source,
format,
width,
height,
compression_quality,
file_path,
} => {
let settings = SaveScreenshot {
source,
format,
width: *width,
height: *height,
compression_quality: *compression_quality,
file_path,
};
client.sources().save_screenshot(settings).await?;
println!("Saved screenshot to path: {:?}", file_path);
}

Commands::Streaming(action) => {
use Streaming::*;
println!("Streaming {:?}", action);
Expand Down

0 comments on commit 3037a96

Please sign in to comment.