@@ -180,6 +180,9 @@ configuration during runtime use the `reload` statement in the command prompt
|
|||||||
Possible configuration values are:
|
Possible configuration values are:
|
||||||
|
|
||||||
* `use_nerdfont`: Turn nerdfont glyphs on/off <true/false>
|
* `use_nerdfont`: Turn nerdfont glyphs on/off <true/false>
|
||||||
|
* `flip_status_indicators`: By default the statusbar will show a play icon when
|
||||||
|
a track is playing and a pause icon when playback is stopped. If this setting
|
||||||
|
is enabled, the behavior is reversed. <true/false>
|
||||||
* `theme`: Set a custom color palette (see below)
|
* `theme`: Set a custom color palette (see below)
|
||||||
* `backend`: Audio backend to use, run `ncspot -h` for a list of devices
|
* `backend`: Audio backend to use, run `ncspot -h` for a list of devices
|
||||||
* `backend_device`: Audio device string to configure the backend
|
* `backend_device`: Audio device string to configure the backend
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pub struct ConfigValues {
|
|||||||
pub keybindings: Option<HashMap<String, String>>,
|
pub keybindings: Option<HashMap<String, String>>,
|
||||||
pub theme: Option<ConfigTheme>,
|
pub theme: Option<ConfigTheme>,
|
||||||
pub use_nerdfont: Option<bool>,
|
pub use_nerdfont: Option<bool>,
|
||||||
|
pub flip_status_indicators: Option<bool>,
|
||||||
pub audio_cache: Option<bool>,
|
pub audio_cache: Option<bool>,
|
||||||
pub audio_cache_size: Option<u32>,
|
pub audio_cache_size: Option<u32>,
|
||||||
pub backend: Option<String>,
|
pub backend: Option<String>,
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ async fn main() {
|
|||||||
spotify.clone(),
|
spotify.clone(),
|
||||||
queue.clone(),
|
queue.clone(),
|
||||||
library.clone(),
|
library.clone(),
|
||||||
cfg.clone(),
|
cfg,
|
||||||
event_manager.clone(),
|
event_manager.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -204,11 +204,7 @@ async fn main() {
|
|||||||
#[cfg(feature = "cover")]
|
#[cfg(feature = "cover")]
|
||||||
let coverview = ui::cover::CoverView::new(queue.clone(), library.clone(), &cfg);
|
let coverview = ui::cover::CoverView::new(queue.clone(), library.clone(), &cfg);
|
||||||
|
|
||||||
let status = ui::statusbar::StatusBar::new(
|
let status = ui::statusbar::StatusBar::new(queue.clone(), library);
|
||||||
queue.clone(),
|
|
||||||
library,
|
|
||||||
cfg.values().use_nerdfont.unwrap_or(false),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
let mut layout = ui::layout::Layout::new(status, &event_manager, theme)
|
||||||
.screen("search", search.with_name("search"))
|
.screen("search", search.with_name("search"))
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ pub struct StatusBar {
|
|||||||
spotify: Spotify,
|
spotify: Spotify,
|
||||||
library: Arc<Library>,
|
library: Arc<Library>,
|
||||||
last_size: Vec2,
|
last_size: Vec2,
|
||||||
use_nerdfont: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusBar {
|
impl StatusBar {
|
||||||
pub fn new(queue: Arc<Queue>, library: Arc<Library>, use_nerdfont: bool) -> StatusBar {
|
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> StatusBar {
|
||||||
let spotify = queue.get_spotify();
|
let spotify = queue.get_spotify();
|
||||||
|
|
||||||
StatusBar {
|
StatusBar {
|
||||||
@@ -29,7 +28,37 @@ impl StatusBar {
|
|||||||
spotify,
|
spotify,
|
||||||
library,
|
library,
|
||||||
last_size: Vec2::new(0, 0),
|
last_size: Vec2::new(0, 0),
|
||||||
use_nerdfont,
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn use_nerdfont(&self) -> bool {
|
||||||
|
self.library.cfg.values().use_nerdfont.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn playback_indicator(&self) -> &str {
|
||||||
|
let status = self.spotify.get_current_status();
|
||||||
|
let nerdfont = self.use_nerdfont();
|
||||||
|
let flipped = self
|
||||||
|
.library
|
||||||
|
.cfg
|
||||||
|
.values()
|
||||||
|
.flip_status_indicators
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
const NF_PLAY: &str = "\u{f909} ";
|
||||||
|
const NF_PAUSE: &str = "\u{f909} ";
|
||||||
|
const NF_STOP: &str = "\u{f909} ";
|
||||||
|
let indicators = match (nerdfont, flipped) {
|
||||||
|
(false, false) => ("▶ ", "▮▮", "◼ "),
|
||||||
|
(false, true) => ("▮▮", "▶ ", "▶ "),
|
||||||
|
(true, false) => (NF_PLAY, NF_PAUSE, NF_STOP),
|
||||||
|
(true, true) => (NF_PAUSE, NF_PLAY, NF_PLAY),
|
||||||
|
};
|
||||||
|
|
||||||
|
match status {
|
||||||
|
PlayerEvent::Playing(_) => indicators.0,
|
||||||
|
PlayerEvent::Paused(_) => indicators.1,
|
||||||
|
PlayerEvent::Stopped | PlayerEvent::FinishedTrack => indicators.2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,27 +99,12 @@ impl View for StatusBar {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
let state_icon = if self.use_nerdfont {
|
|
||||||
match self.spotify.get_current_status() {
|
|
||||||
PlayerEvent::Playing(_) => "\u{f909} ",
|
|
||||||
PlayerEvent::Paused(_) => "\u{f8e3} ",
|
|
||||||
PlayerEvent::Stopped | PlayerEvent::FinishedTrack => "\u{f9da} ",
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
match self.spotify.get_current_status() {
|
|
||||||
PlayerEvent::Playing(_) => "▶ ",
|
|
||||||
PlayerEvent::Paused(_) => "▮▮",
|
|
||||||
PlayerEvent::Stopped | PlayerEvent::FinishedTrack => "◼ ",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
printer.with_color(style, |printer| {
|
printer.with_color(style, |printer| {
|
||||||
printer.print((1, 1), &state_icon);
|
printer.print((1, 1), self.playback_indicator());
|
||||||
});
|
});
|
||||||
|
|
||||||
let updating = if !*self.library.is_done.read().unwrap() {
|
let updating = if !*self.library.is_done.read().unwrap() {
|
||||||
if self.use_nerdfont {
|
if self.use_nerdfont() {
|
||||||
"\u{f9e5} "
|
"\u{f9e5} "
|
||||||
} else {
|
} else {
|
||||||
"[U] "
|
"[U] "
|
||||||
@@ -99,7 +113,7 @@ impl View for StatusBar {
|
|||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
let repeat = if self.use_nerdfont {
|
let repeat = if self.use_nerdfont() {
|
||||||
match self.queue.get_repeat() {
|
match self.queue.get_repeat() {
|
||||||
RepeatSetting::None => "",
|
RepeatSetting::None => "",
|
||||||
RepeatSetting::RepeatPlaylist => "\u{f955} ",
|
RepeatSetting::RepeatPlaylist => "\u{f955} ",
|
||||||
@@ -114,7 +128,7 @@ impl View for StatusBar {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let shuffle = if self.queue.get_shuffle() {
|
let shuffle = if self.queue.get_shuffle() {
|
||||||
if self.use_nerdfont {
|
if self.use_nerdfont() {
|
||||||
"\u{f99c} "
|
"\u{f99c} "
|
||||||
} else {
|
} else {
|
||||||
"[Z] "
|
"[Z] "
|
||||||
@@ -168,18 +182,6 @@ impl View for StatusBar {
|
|||||||
printer.print((0, 0), &"━".repeat(duration_width + 1));
|
printer.print((0, 0), &"━".repeat(duration_width + 1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// if let Some(Playable::Track(ref t)) = self.queue.get_current() {
|
|
||||||
// let saved = if self.library.is_saved_track(&Playable::Track(t.clone())) {
|
|
||||||
// if self.use_nerdfont {
|
|
||||||
// "\u{f62b} "
|
|
||||||
// } else {
|
|
||||||
// "✓ "
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// ""
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(&mut self, size: Vec2) {
|
fn layout(&mut self, size: Vec2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user