mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-07-26 05:46:59 +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:
@@ -9,14 +9,13 @@ use itertools::Itertools;
|
||||
use pwsp_lib::{
|
||||
types::{
|
||||
audio_player::PlayerState,
|
||||
config::GuiConfig,
|
||||
config::HotkeyConfig,
|
||||
config::{GuiConfig, HotkeyConfig},
|
||||
gui::{AppState, AudioPlayerState},
|
||||
socket::Request,
|
||||
},
|
||||
utils::{
|
||||
daemon::get_daemon_config,
|
||||
gui::{get_gui_config, make_request_async, make_request_sync, start_app_state_thread},
|
||||
utils::gui::{
|
||||
get_daemon_config, get_gui_config, make_request_async, make_request_sync,
|
||||
start_app_state_thread, update_daemon_config,
|
||||
},
|
||||
};
|
||||
use rfd::FileDialog;
|
||||
@@ -130,10 +129,11 @@ impl SoundpadGui {
|
||||
pub fn set_input(&mut self, name: String) {
|
||||
make_request_async(Request::set_input(&name));
|
||||
|
||||
if self.config.save_input {
|
||||
let mut daemon_config = get_daemon_config();
|
||||
if self.config.save_input
|
||||
&& let Ok(mut daemon_config) = get_daemon_config()
|
||||
{
|
||||
daemon_config.default_input_name = Some(name);
|
||||
daemon_config.save_to_file().ok();
|
||||
update_daemon_config(&daemon_config).ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use eframe::{App, Frame as EFrame};
|
||||
use egui::{CentralPanel, Context, ThemePreference};
|
||||
use pwsp_lib::{
|
||||
types::{config::PreferredTheme, socket::Request},
|
||||
utils::{daemon::get_daemon_config, gui::make_request_async},
|
||||
utils::gui::{get_daemon_config, make_request_async, update_daemon_config},
|
||||
};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -85,10 +85,11 @@ impl App for SoundpadGui {
|
||||
self.app_state.ignore_volume_update_until =
|
||||
Some(Instant::now() + Duration::from_millis(300));
|
||||
|
||||
if self.config.save_volume {
|
||||
let mut daemon_config = get_daemon_config();
|
||||
if self.config.save_volume
|
||||
&& let Ok(mut daemon_config) = get_daemon_config()
|
||||
{
|
||||
daemon_config.default_volume = Some(self.app_state.volume_slider_value);
|
||||
daemon_config.save_to_file().ok();
|
||||
update_daemon_config(&daemon_config).ok();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user