add configuration value to drop default keybindings

resolves #204
This commit is contained in:
Henrik Friedrichsen
2020-06-18 19:33:19 +02:00
parent d36fb4fe40
commit 65126c5c78
4 changed files with 14 additions and 9 deletions

View File

@@ -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);