mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-07-27 14:14:13 +00:00
feat(daemon, cli): global DaemonConfig and an ability to get/save it using cli (#174)
* use one global Arc<DaemonConfig> * implement commands * replace Arc<DaemonConfig> with Arc<Mutex<DaemonConfig>> and fix pwsp-gui * add pwsp-cli support * replace serde_json::to_string_pretty with to_string * refactor * implement UpdateDaemonConfigCommand and use it in pwsp-gui so it now uses real in-memory config, not the saved one * implement utils::gui get_daemon_config and update_daemon_config to simplify code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
types::{
|
||||
audio_player::FullState,
|
||||
config::{GuiConfig, HotkeyConfig},
|
||||
config::{DaemonConfig, GuiConfig, HotkeyConfig},
|
||||
gui::AudioPlayerState,
|
||||
socket::{Request, Response},
|
||||
},
|
||||
@@ -24,6 +24,19 @@ pub fn get_gui_config() -> GuiConfig {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn update_daemon_config(new_config: &DaemonConfig) -> Result<()> {
|
||||
make_request_sync(Request::update_daemon_config(new_config))?;
|
||||
make_request_async(Request::save_daemon_config());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_daemon_config() -> Result<DaemonConfig> {
|
||||
let response = make_request_sync(Request::get_daemon_config())?;
|
||||
let config: DaemonConfig = serde_json::from_str(&response.message)?;
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
pub fn make_request_sync(request: Request) -> Result<Response> {
|
||||
tokio::task::block_in_place(|| {
|
||||
tokio::runtime::Handle::current()
|
||||
|
||||
Reference in New Issue
Block a user