mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
feat: get daemon's version using pwsp-cli
pwsp-cli get daemon-version
This commit is contained in:
@@ -92,6 +92,8 @@ enum GetCommands {
|
|||||||
Input,
|
Input,
|
||||||
/// All audio inputs
|
/// All audio inputs
|
||||||
Inputs,
|
Inputs,
|
||||||
|
/// Version of the daemon
|
||||||
|
DaemonVersion,
|
||||||
/// Full player state
|
/// Full player state
|
||||||
FullState,
|
FullState,
|
||||||
}
|
}
|
||||||
@@ -148,6 +150,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
GetCommands::Tracks => Request::get_tracks(),
|
GetCommands::Tracks => Request::get_tracks(),
|
||||||
GetCommands::Input => Request::get_input(),
|
GetCommands::Input => Request::get_input(),
|
||||||
GetCommands::Inputs => Request::get_inputs(),
|
GetCommands::Inputs => Request::get_inputs(),
|
||||||
|
GetCommands::DaemonVersion => Request::get_daemon_version(),
|
||||||
GetCommands::FullState => Request::get_full_state(),
|
GetCommands::FullState => Request::get_full_state(),
|
||||||
},
|
},
|
||||||
Commands::Set { parameter } => match parameter {
|
Commands::Set { parameter } => match parameter {
|
||||||
|
|||||||
+10
-1
@@ -82,6 +82,8 @@ pub struct ToggleLoopCommand {
|
|||||||
pub id: Option<u32>,
|
pub id: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct GetDaemonVersionCommand {}
|
||||||
|
|
||||||
pub struct GetFullStateCommand {}
|
pub struct GetFullStateCommand {}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -347,6 +349,13 @@ impl Executable for ToggleLoopCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Executable for GetDaemonVersionCommand {
|
||||||
|
async fn execute(&self) -> Response {
|
||||||
|
Response::new(true, env!("CARGO_PKG_VERSION"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl Executable for GetFullStateCommand {
|
impl Executable for GetFullStateCommand {
|
||||||
async fn execute(&self) -> Response {
|
async fn execute(&self) -> Response {
|
||||||
@@ -374,7 +383,7 @@ impl Executable for GetFullStateCommand {
|
|||||||
tracks: audio_player.get_tracks(),
|
tracks: audio_player.get_tracks(),
|
||||||
volume: audio_player.volume,
|
volume: audio_player.volume,
|
||||||
current_input: current_input_nick,
|
current_input: current_input_nick,
|
||||||
all_inputs,
|
all_inputs: all_inputs,
|
||||||
};
|
};
|
||||||
|
|
||||||
Response::new(true, serde_json::to_string(&full_state).unwrap())
|
Response::new(true, serde_json::to_string(&full_state).unwrap())
|
||||||
|
|||||||
@@ -156,6 +156,10 @@ impl Request {
|
|||||||
Request::new("toggle_loop", args)
|
Request::new("toggle_loop", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_daemon_version() -> Self {
|
||||||
|
Request::new("get_daemon_version", vec![])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_full_state() -> Self {
|
pub fn get_full_state() -> Self {
|
||||||
Request::new("get_full_state", vec![])
|
Request::new("get_full_state", vec![])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ pub fn parse_command(request: &Request) -> Option<Box<dyn Executable + Send>> {
|
|||||||
Some(Box::new(SetLoopCommand { enabled, id }))
|
Some(Box::new(SetLoopCommand { enabled, id }))
|
||||||
}
|
}
|
||||||
"toggle_loop" => Some(Box::new(ToggleLoopCommand { id })),
|
"toggle_loop" => Some(Box::new(ToggleLoopCommand { id })),
|
||||||
|
"get_daemon_version" => Some(Box::new(GetDaemonVersionCommand {})),
|
||||||
"get_full_state" => Some(Box::new(GetFullStateCommand {})),
|
"get_full_state" => Some(Box::new(GetFullStateCommand {})),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user