mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
Compare commits
109 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87bd6db446 | |||
| 1fc6c8829c | |||
| a63e44a4a8 | |||
| 5de29f3d14 | |||
| c4028f1d56 | |||
| e39883e133 | |||
| 7e793f428f | |||
| 238e0b464b | |||
| 59bee29609 | |||
| 12725d0add | |||
| bb83ac54ef | |||
| adfc0f25c4 | |||
| 572aa33c95 | |||
| 3850a9ce10 | |||
| b7dc54c2cb | |||
| 0357c239d5 | |||
| cb1bd42f83 | |||
| 113eb38767 | |||
| ab68648ef6 | |||
| e10b6f1449 | |||
| ede5028d35 | |||
| f721e4612a | |||
| ef9125024c | |||
| 12c70f0edb | |||
| eae455f0b8 | |||
| e0a55dffa6 | |||
| 6a755ad068 | |||
| 7809a8c9ff | |||
| 76a5f069ab | |||
| ae84b345a4 | |||
| cdd58a04ed | |||
| 271955c777 | |||
| 5b475d1f07 | |||
| 5509b80f3e | |||
| 2a31865822 | |||
| 258467d5bc | |||
| 51ab5eacbc | |||
| 1957a5e2fd | |||
| 5f852343da | |||
| aee48c8f8d | |||
| c63b220d92 | |||
| a4708f1812 | |||
| 3754121ab5 | |||
| a665939137 | |||
| 974fdc9411 | |||
| 9a1107fb41 | |||
| ad2c15f9e3 | |||
| 6d66b57d1b | |||
| 869b67738c | |||
| af3e19d794 | |||
| b42498d188 | |||
| 60975110da | |||
| 05f243b322 | |||
| 0188cac476 | |||
| 3e93ba14e1 | |||
| 939dbea12b | |||
| a4d3111c6d | |||
| 9053056dfa | |||
| e9e3f67735 | |||
| 9238e6563b | |||
| 939b01b587 | |||
| 489878c813 | |||
| c1c1bfd487 | |||
| 2028a728e0 | |||
| e627e71cf6 | |||
| dfe7a7e971 | |||
| 0535744b30 | |||
| 3170e9f30a | |||
| 7ddd2c0dab | |||
| 8590dcceae | |||
| fb6714aeee | |||
| 34886e44a6 | |||
| ede04dd3f8 | |||
| ad892dda29 | |||
| 3a02e9991c | |||
| 5d9d20417b | |||
| d1994d7226 | |||
| b526d67d2f | |||
| c641ec4f31 | |||
| 5bce45c97f | |||
| adfdf7db69 | |||
| 7a7e0f741a | |||
| d86cd6c5d3 | |||
| 61ba71d38e | |||
| 7116ccf487 | |||
| 654ef0d973 | |||
| e9756b0681 | |||
| f72fe588e3 | |||
| 53533c35ef | |||
| 382ddb0ff2 | |||
| 714f81ab34 | |||
| 3c028972fe | |||
| 7e3ff23156 | |||
| 09cec44a5b | |||
| ead17d26a9 | |||
| dfa1cfbb15 | |||
| a70c991711 | |||
| 8c0704ce57 | |||
| 00196bfe7f | |||
| 428fb4064d | |||
| e2b003be31 | |||
| 79176432de | |||
| 9e0a307106 | |||
| 428565594d | |||
| 1d0e3036e9 | |||
| b31f4c8c45 | |||
| 84b6f8ce20 | |||
| c797b204a2 | |||
| faa29d8805 |
Generated
+6
-15
@@ -1726,13 +1726,13 @@ checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.11"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df15f6eac291ed1cf25865b1ee60399f57e7c227e7f51bdbd4c5270396a9ed50"
|
||||
checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"libc",
|
||||
"redox_syscall 0.6.0",
|
||||
"redox_syscall 0.5.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1864,9 +1864,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "moxcms"
|
||||
version = "0.7.11"
|
||||
version = "0.7.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac9557c559cd6fc9867e122e20d2cbefc9ca29d80d027a8e39310920ed2f0a97"
|
||||
checksum = "80986bbbcf925ebd3be54c26613d861255284584501595cf418320c078945608"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"pxfm",
|
||||
@@ -2601,7 +2601,7 @@ checksum = "3eb8486b569e12e2c32ad3e204dbaba5e4b5b216e9367044f25f1dba42341773"
|
||||
|
||||
[[package]]
|
||||
name = "pwsp"
|
||||
version = "1.2.0"
|
||||
version = "1.1.4"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
@@ -2730,15 +2730,6 @@ dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec96166dafa0886eb81fe1c0a388bece180fbef2135f97c1e2cf8302e74b43b5"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pwsp"
|
||||
version = "1.2.0"
|
||||
version = "1.1.4"
|
||||
edition = "2024"
|
||||
authors = ["arabian"]
|
||||
description = "PWSP lets you play audio files through your microphone. Has both CLI and GUI clients."
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
%global cargo_install_lib 0
|
||||
|
||||
Name: pwsp
|
||||
Version: 1.2.0
|
||||
Version: 1.1.4
|
||||
Release: %autorelease
|
||||
Summary: Lets you play audio files through your microphone
|
||||
|
||||
|
||||
+7
-10
@@ -14,17 +14,17 @@ struct Cli {
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
enum Commands {
|
||||
/// Perform an action (ping, pause, resume, toggle-pause, stop, play)
|
||||
/// Perform an action (ping, pause, resume, stop, play)
|
||||
Action {
|
||||
#[clap(subcommand)]
|
||||
action: Actions,
|
||||
},
|
||||
/// Get information from the player (is paused, volume, position, duration, state, current-file-path, input, inputs)
|
||||
/// Get information from the player (is paused, volume, position, state)
|
||||
Get {
|
||||
#[clap(subcommand)]
|
||||
parameter: GetCommands,
|
||||
},
|
||||
/// Set information in the player (volume, position, input)
|
||||
/// Set information in the player (volume, position)
|
||||
Set {
|
||||
#[clap(subcommand)]
|
||||
parameter: SetCommands,
|
||||
@@ -39,8 +39,6 @@ enum Actions {
|
||||
Pause,
|
||||
/// Resume audio playback
|
||||
Resume,
|
||||
/// Toggle pause
|
||||
TogglePause,
|
||||
/// Stop audio playback and clear the queue
|
||||
Stop,
|
||||
/// Play a file
|
||||
@@ -53,11 +51,11 @@ enum GetCommands {
|
||||
IsPaused,
|
||||
/// Playback volume
|
||||
Volume,
|
||||
/// Playback position (in seconds)
|
||||
/// Playback position
|
||||
Position,
|
||||
/// Duration of the current file
|
||||
Duration,
|
||||
/// Player state (Playing, Paused or Stopped)
|
||||
/// Player state
|
||||
State,
|
||||
/// Current playing file path
|
||||
CurrentFilePath,
|
||||
@@ -71,9 +69,9 @@ enum GetCommands {
|
||||
enum SetCommands {
|
||||
/// Playback volume
|
||||
Volume { volume: f32 },
|
||||
/// Playback position (in seconds)
|
||||
/// Playback position
|
||||
Position { position: f32 },
|
||||
/// Audio input id (see pwsp-cli get inputs)
|
||||
/// Input
|
||||
Input { name: String },
|
||||
}
|
||||
|
||||
@@ -88,7 +86,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
Actions::Ping => Request::ping(),
|
||||
Actions::Pause => Request::pause(),
|
||||
Actions::Resume => Request::resume(),
|
||||
Actions::TogglePause => Request::toggle_pause(),
|
||||
Actions::Stop => Request::stop(),
|
||||
Actions::Play { file_path } => Request::play(file_path.to_str().unwrap()),
|
||||
},
|
||||
|
||||
+12
-23
@@ -1,7 +1,7 @@
|
||||
use crate::gui::{SUPPORTED_EXTENSIONS, SoundpadGui};
|
||||
use crate::gui::SoundpadGui;
|
||||
use egui::{
|
||||
Align, AtomExt, Button, Color32, ComboBox, FontFamily, Label, Layout, RichText, ScrollArea,
|
||||
Slider, TextEdit, Ui, Vec2,
|
||||
AtomExt, Button, Color32, ComboBox, FontFamily, Label, RichText, ScrollArea, Slider, TextEdit,
|
||||
Ui, Vec2,
|
||||
};
|
||||
use egui_material_icons::icons;
|
||||
use pwsp::types::audio_player::PlayerState;
|
||||
@@ -48,15 +48,10 @@ impl SoundpadGui {
|
||||
&mut self.config.save_scale_factor,
|
||||
"Always remember UI scale factor",
|
||||
);
|
||||
let pause_on_exit_response = ui.checkbox(
|
||||
&mut self.config.pause_on_exit,
|
||||
"Pause audio playback when the window is closed",
|
||||
);
|
||||
|
||||
if save_volume_response.changed()
|
||||
|| save_input_response.changed()
|
||||
|| save_scale_response.changed()
|
||||
|| pause_on_exit_response.changed()
|
||||
{
|
||||
self.config.save_to_file().ok();
|
||||
}
|
||||
@@ -187,8 +182,6 @@ impl SoundpadGui {
|
||||
ui.set_min_height(area_size.y);
|
||||
|
||||
ScrollArea::vertical().id_salt(0).show(ui, |ui| {
|
||||
ui.set_min_width(area_size.x);
|
||||
|
||||
let mut dirs: Vec<PathBuf> = self.app_state.dirs.iter().cloned().collect();
|
||||
dirs.sort();
|
||||
for path in dirs.iter() {
|
||||
@@ -223,18 +216,10 @@ impl SoundpadGui {
|
||||
}
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
let add_dirs_button = Button::new(icons::ICON_ADD).frame(false);
|
||||
let add_dirs_button_response = ui.add_sized([18.0, 18.0], add_dirs_button);
|
||||
if add_dirs_button_response.clicked() {
|
||||
self.add_dirs();
|
||||
}
|
||||
});
|
||||
|
||||
ui.with_layout(Layout::bottom_up(Align::Min), |ui| {
|
||||
let play_file_button = Button::new("Play file");
|
||||
let play_file_button_response = ui.add(play_file_button);
|
||||
if play_file_button_response.clicked() {
|
||||
self.open_file();
|
||||
let add_dir_button = egui::Button::new(icons::ICON_ADD).frame(false);
|
||||
let add_dir_button_response = ui.add_sized([18.0, 18.0], add_dir_button);
|
||||
if add_dir_button_response.clicked() {
|
||||
self.add_dir();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -242,6 +227,10 @@ impl SoundpadGui {
|
||||
}
|
||||
|
||||
fn draw_files(&mut self, ui: &mut Ui, area_size: Vec2) {
|
||||
let extensions = [
|
||||
"mp3", "wav", "ogg", "flac", "mp4", "m4a", "aac", "mov", "mkv", "webm", "avi",
|
||||
];
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let search_field = ui.add_sized(
|
||||
@@ -267,7 +256,7 @@ impl SoundpadGui {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !SUPPORTED_EXTENSIONS
|
||||
if !extensions
|
||||
.contains(&entry_path.extension().unwrap_or_default().to_str().unwrap())
|
||||
{
|
||||
continue;
|
||||
|
||||
+3
-23
@@ -23,10 +23,6 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
const SUPPORTED_EXTENSIONS: [&str; 11] = [
|
||||
"mp3", "wav", "ogg", "flac", "mp4", "m4a", "aac", "mov", "mkv", "webm", "avi",
|
||||
];
|
||||
|
||||
struct SoundpadGui {
|
||||
pub app_state: AppState,
|
||||
pub config: GuiConfig,
|
||||
@@ -72,19 +68,10 @@ impl SoundpadGui {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn open_file(&mut self) {
|
||||
let file_dialog = FileDialog::new().add_filter("Audio File", &SUPPORTED_EXTENSIONS);
|
||||
if let Some(path) = file_dialog.pick_file() {
|
||||
self.play_file(&path);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_dirs(&mut self) {
|
||||
pub fn add_dir(&mut self) {
|
||||
let file_dialog = FileDialog::new();
|
||||
if let Some(paths) = file_dialog.pick_folders() {
|
||||
for path in paths {
|
||||
if let Some(path) = file_dialog.pick_folder() {
|
||||
self.app_state.dirs.insert(path);
|
||||
}
|
||||
self.config.dirs = self.app_state.dirs.clone();
|
||||
self.config.save_to_file().ok();
|
||||
}
|
||||
@@ -96,7 +83,6 @@ impl SoundpadGui {
|
||||
&& current_dir == path
|
||||
{
|
||||
self.app_state.current_dir = None;
|
||||
self.app_state.files.clear();
|
||||
}
|
||||
self.config.dirs = self.app_state.dirs.clone();
|
||||
self.config.save_to_file().ok();
|
||||
@@ -152,13 +138,7 @@ pub async fn run() -> Result<(), Box<dyn Error>> {
|
||||
Ok(Box::new(SoundpadGui::new(&cc.egui_ctx)))
|
||||
}),
|
||||
) {
|
||||
Ok(_) => {
|
||||
let config = get_gui_config();
|
||||
if config.pause_on_exit {
|
||||
make_request_sync(Request::pause()).ok();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
+1
-22
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
types::{audio_player::PlayerState, socket::Response},
|
||||
types::socket::Response,
|
||||
utils::{daemon::get_audio_player, pipewire::get_all_devices},
|
||||
};
|
||||
use async_trait::async_trait;
|
||||
@@ -16,8 +16,6 @@ pub struct PauseCommand {}
|
||||
|
||||
pub struct ResumeCommand {}
|
||||
|
||||
pub struct TogglePauseCommand {}
|
||||
|
||||
pub struct StopCommand {}
|
||||
|
||||
pub struct IsPausedCommand {}
|
||||
@@ -77,25 +75,6 @@ impl Executable for ResumeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Executable for TogglePauseCommand {
|
||||
async fn execute(&self) -> Response {
|
||||
let mut audio_player = get_audio_player().await.lock().await;
|
||||
|
||||
if audio_player.get_state() == PlayerState::Stopped {
|
||||
return Response::new(false, "Audio is not playing");
|
||||
}
|
||||
|
||||
if audio_player.is_paused() {
|
||||
audio_player.resume();
|
||||
Response::new(true, "Audio was resumed")
|
||||
} else {
|
||||
audio_player.pause();
|
||||
Response::new(true, "Audio was paused")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Executable for StopCommand {
|
||||
async fn execute(&self) -> Response {
|
||||
|
||||
@@ -36,7 +36,6 @@ pub struct GuiConfig {
|
||||
pub save_volume: bool,
|
||||
pub save_input: bool,
|
||||
pub save_scale_factor: bool,
|
||||
pub pause_on_exit: bool,
|
||||
|
||||
pub dirs: HashSet<PathBuf>,
|
||||
}
|
||||
@@ -49,7 +48,6 @@ impl Default for GuiConfig {
|
||||
save_volume: false,
|
||||
save_input: false,
|
||||
save_scale_factor: false,
|
||||
pause_on_exit: false,
|
||||
|
||||
dirs: HashSet::default(),
|
||||
}
|
||||
|
||||
@@ -32,10 +32,6 @@ impl Request {
|
||||
Request::new("resume", vec![])
|
||||
}
|
||||
|
||||
pub fn toggle_pause() -> Self {
|
||||
Request::new("toggle_pause", vec![])
|
||||
}
|
||||
|
||||
pub fn stop() -> Self {
|
||||
Request::new("stop", vec![])
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ pub fn parse_command(request: &Request) -> Option<Box<dyn Executable + Send>> {
|
||||
"ping" => Some(Box::new(PingCommand {})),
|
||||
"pause" => Some(Box::new(PauseCommand {})),
|
||||
"resume" => Some(Box::new(ResumeCommand {})),
|
||||
"toggle_pause" => Some(Box::new(TogglePauseCommand {})),
|
||||
"stop" => Some(Box::new(StopCommand {})),
|
||||
"is_paused" => Some(Box::new(IsPausedCommand {})),
|
||||
"get_state" => Some(Box::new(GetStateCommand {})),
|
||||
|
||||
Reference in New Issue
Block a user