Add config values to override shuffle/repeat state
This commit is contained in:
@@ -189,6 +189,8 @@ Possible configuration values are:
|
|||||||
* `bitrate`: The audio bitrate to use for streaming, can be 96, 160, or 320 (default is 320)
|
* `bitrate`: The audio bitrate to use for streaming, can be 96, 160, or 320 (default is 320)
|
||||||
* `album_column`: Show album column for tracks, on by default <true/false>
|
* `album_column`: Show album column for tracks, on by default <true/false>
|
||||||
* `gapless`: Allows gapless playback <true/false> (default is false)
|
* `gapless`: Allows gapless playback <true/false> (default is false)
|
||||||
|
* `shuffle`: Set default shuffle state <true/false>
|
||||||
|
* `repeat`: Set default repeat mode <off/track/playlist>
|
||||||
|
|
||||||
|
|
||||||
Keybindings can be configured in `[keybindings]` section in `config.toml`, e.g. as such:
|
Keybindings can be configured in `[keybindings]` section in `config.toml`, e.g. as such:
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ pub struct ConfigValues {
|
|||||||
pub bitrate: Option<u32>,
|
pub bitrate: Option<u32>,
|
||||||
pub album_column: Option<bool>,
|
pub album_column: Option<bool>,
|
||||||
pub gapless: Option<bool>,
|
pub gapless: Option<bool>,
|
||||||
|
pub shuffle: Option<bool>,
|
||||||
|
pub repeat: Option<queue::RepeatSetting>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
|
||||||
@@ -85,12 +87,20 @@ impl Config {
|
|||||||
process::exit(1);
|
process::exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let userstate = {
|
let mut userstate = {
|
||||||
let path = config_path("userstate.toml");
|
let path = config_path("userstate.toml");
|
||||||
load_or_generate_default(path, |_| Ok(UserState::default()), true)
|
load_or_generate_default(path, |_| Ok(UserState::default()), true)
|
||||||
.expect("could not load user state")
|
.expect("could not load user state")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if let Some(shuffle) = values.shuffle {
|
||||||
|
userstate.shuffle = shuffle;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(repeat) = values.repeat {
|
||||||
|
userstate.repeat = repeat;
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
values: RwLock::new(values),
|
values: RwLock::new(values),
|
||||||
state: RwLock::new(userstate),
|
state: RwLock::new(userstate),
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ use crate::{config::Config, spotify::PlayerEvent};
|
|||||||
|
|
||||||
#[derive(Display, Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Display, Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
pub enum RepeatSetting {
|
pub enum RepeatSetting {
|
||||||
|
#[serde(rename = "off")]
|
||||||
None,
|
None,
|
||||||
|
#[serde(rename = "playlist")]
|
||||||
RepeatPlaylist,
|
RepeatPlaylist,
|
||||||
|
#[serde(rename = "track")]
|
||||||
RepeatTrack,
|
RepeatTrack,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user