@@ -128,6 +128,8 @@ values are:
|
||||
<true/false>
|
||||
* `volnorm`: Enable or disable volume normalization, off by default <true/false>
|
||||
* `volnorm_pregain`: Normalization pregain to apply (if enabled)
|
||||
* `default_keybindings`: If disabled, the default keybindings are discarded, off
|
||||
by default <true/false>
|
||||
|
||||
Keybindings can be configured in `[keybindings]` section in `config.toml`, e.g. as such:
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ use std::time::Duration;
|
||||
use crate::command::{
|
||||
parse, Command, GotoMode, MoveAmount, MoveMode, SeekDirection, ShiftMode, TargetMode,
|
||||
};
|
||||
use crate::config::Config;
|
||||
use crate::library::Library;
|
||||
use crate::queue::{Queue, RepeatSetting};
|
||||
use crate::spotify::{Spotify, VOLUME_PERCENT};
|
||||
@@ -36,11 +37,16 @@ impl CommandManager {
|
||||
spotify: Arc<Spotify>,
|
||||
queue: Arc<Queue>,
|
||||
library: Arc<Library>,
|
||||
bindings: Option<HashMap<String, String>>,
|
||||
config: &Config,
|
||||
) -> CommandManager {
|
||||
let mut kb = Self::default_keybindings();
|
||||
let mut kb = if config.default_keybindings.unwrap_or(true) {
|
||||
Self::default_keybindings()
|
||||
} else {
|
||||
HashMap::new()
|
||||
};
|
||||
let custom_bindings: Option<HashMap<String, String>> = config.keybindings.clone();
|
||||
|
||||
for (key, command) in bindings.unwrap_or_default() {
|
||||
for (key, command) in custom_bindings.unwrap_or_default() {
|
||||
if let Some(command) = parse(&command) {
|
||||
info!("Custom keybinding: {} -> {:?}", key, command);
|
||||
kb.insert(key, command);
|
||||
|
||||
@@ -9,6 +9,7 @@ pub const CLIENT_ID: &str = "d420a117a32841c2b3474932e49fb54b";
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
pub struct Config {
|
||||
pub default_keybindings: Option<bool>,
|
||||
pub keybindings: Option<HashMap<String, String>>,
|
||||
pub theme: Option<ConfigTheme>,
|
||||
pub use_nerdfont: Option<bool>,
|
||||
|
||||
@@ -216,12 +216,8 @@ fn main() {
|
||||
cfg.use_nerdfont.unwrap_or(false),
|
||||
));
|
||||
|
||||
let mut cmd_manager = CommandManager::new(
|
||||
spotify.clone(),
|
||||
queue.clone(),
|
||||
library.clone(),
|
||||
cfg.keybindings.clone(),
|
||||
);
|
||||
let mut cmd_manager =
|
||||
CommandManager::new(spotify.clone(), queue.clone(), library.clone(), &cfg);
|
||||
cmd_manager.register_all();
|
||||
|
||||
let cmd_manager = Arc::new(cmd_manager);
|
||||
|
||||
Reference in New Issue
Block a user