Skip to content

Commit

Permalink
feat: add toggle pause param
Browse files Browse the repository at this point in the history
this send `killall -SIGUSR1 push2talk`
  • Loading branch information
cyrinux committed Oct 29, 2023
1 parent a5efa01 commit 41650c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "push2talk"
version = "1.0.0"
version = "1.0.2"
edition = "2021"
authors = ["Cyril Levis", "Maxim Baz"]
categories = ["gui", "audio"]
Expand Down
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use signal_hook::flag;
use std::error::Error;
use std::fs::OpenOptions;
use std::path::PathBuf;
use std::process::Command;
use std::{
cell::Cell,
env,
Expand All @@ -23,9 +24,12 @@ use std::{
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[arg(short, long)]
/// List sources devices
#[arg(short, long)]
list_devices: bool,
/// Toggle pause
#[arg(short, long)]
toggle_pause: bool,
}

fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -38,6 +42,16 @@ fn main() -> Result<(), Box<dyn Error>> {
return Ok(());
}

// Send pause signal
if cli.toggle_pause {
Command::new("killall")
.args(["-SIGUSR1", "push2talk"])
.spawn()
.expect("Can't pause push2talk");
println!("Toggle pause.");
return Ok(());
}

// Ensure that only one instance run
let lock_file = take_lock()?;
if lock_file.try_lock_exclusive().is_err() {
Expand Down

0 comments on commit 41650c2

Please sign in to comment.