Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to cloofy. The format follows [Keep a Changelog](https://kee

## [Unreleased]

### Added

- **Your terminal's colors.** Settings has Colors now. **Terminal** takes your terminal's background and text, with the shades in between mixed from them, so cloofy looks at home in a purple Ptyxis on Ubuntu or any other theme. **Auto** stays as before: Omarchy's theme there, cloofy's own dark colors elsewhere, which **cloofy** keeps everywhere.
- **Your own colors.** Any of cloofy's colors in `~/.config/cloofy/theme.toml`, such as `bg = "#2b0a3d"`, go over the others. cloofy follows the file as you edit it.

### Changed

- **Rust 1.90** or newer builds cloofy from source, for the current D-Bus library on Linux and the library that draws Sixel images.
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ Installed with Homebrew, mise, a system package or Nix, cloofy leaves its update

## Settings

<kbd>,</kbd>, the command palette, or a click on your name in the top bar opens the Settings page: crossfade, cover art and how covers are drawn, the accent color, icons, power saving, song notifications and update checks. Changes apply at once and cloofy saves them in `~/.config/cloofy/config.toml`, so there's no need to edit the file. You still can; it's read at start:
<kbd>,</kbd>, the command palette, or a click on your name in the top bar opens the Settings page: crossfade, cover art and how covers are drawn, the colors, the accent color, icons, power saving, song notifications and update checks. Changes apply at once and cloofy saves them in `~/.config/cloofy/config.toml`, so there's no need to edit the file. You still can; it's read at start:

```toml
client_id = "your client id"
services = ["ytmusic"] # "spotify", "ytmusic" or both, in the switch's order; every one built in when missing
crossfade = 6 # seconds tracks overlap, 0 to 12; off when missing
covers = false # no cover art, for slower computers; on when missing
colors = "terminal" # "cloofy" or "terminal"; Omarchy's theme there, cloofy's own elsewhere, when missing
accent = "violet" # "theme", "green", "violet", "pink", "blue" or "orange"; follows the cover when missing
images = "blocks" # "kitty", "sixel", "iterm2" or "blocks"; detected from the terminal when missing
icons = "nerd" # "nerd" or "text"; detected from the terminal when missing
Expand All @@ -236,7 +237,9 @@ update_check = false # don't look for new releases at start; on when missi
credentials = "keychain" # macOS: sign-ins in the Keychain instead of files (only here)
```

The installer writes `services` with what you listen to. One config file serves every build, so a build leaves out the services it doesn't have. The `"theme"` accent is the Omarchy theme's, and cloofy's green elsewhere.
The installer writes `services` with what you listen to. One config file serves every build, so a build leaves out the services it doesn't have. The `"theme"` accent is the one of the colors in use: `theme.toml`'s when it sets one, else the Omarchy theme's with Colors on Auto, and cloofy's green otherwise, also with Terminal.

cloofy draws with its own dark colors, or with Omarchy's theme. With Colors set to Terminal, it takes your terminal's background and text instead, with the shades in between. To pick colors yourself, put any of `bg`, `surface`, `player`, `raised`, `text`, `muted`, `faint`, `accent` and the [others](integrations/omarchy/cloofy.toml.tpl) in `~/.config/cloofy/theme.toml`, as `bg = "#2b0a3d"`; they go over whichever colors are set, and cloofy follows the file as you edit it.

Power saving stops animations and redraws less often. Unless set otherwise, it turns on by itself with Low Power Mode on macOS and the Power Saver profile on Linux.

Expand Down
3 changes: 3 additions & 0 deletions crates/cloofy-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub struct Config {
pub power_saving: Option<String>,
/// A color name such as `"violet"`; follows the playing cover when missing.
pub accent: Option<String>,
/// `"cloofy"` or `"terminal"`: cloofy's own colors, or the terminal's background and text.
/// Omarchy's theme where there is one, cloofy's own elsewhere, when missing.
pub colors: Option<String>,
/// How covers reach the terminal: `"kitty"`, `"sixel"`, `"iterm2"` or `"blocks"`; detected
/// from the terminal when missing.
pub images: Option<String>,
Expand Down
2 changes: 1 addition & 1 deletion crates/cloofy-tui/src/app/browsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ mod tests {
Paths { config: root.join("config"), data: root.join("data"), cache: root.join("cache"), keychain: false };
let (tx, _) = mpsc::unbounded_channel();
let loader = Loader::for_tests(services, problems, tx);
App::new(loader, Preferences::default(), Start::Restore(Box::new(state)), paths, None, None)
App::new(loader, Preferences::default(), Start::Restore(Box::new(state)), paths, None, None, None)
}

fn page(view: SavedView) -> Page {
Expand Down
20 changes: 13 additions & 7 deletions crates/cloofy-tui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use ratatui::{
use crate::clock::Instant;
use crate::{
backend::{self, Player, Remote, Service},
colors::Colors,
commands::Command,
fx::{Effect, Effects},
graphics::{INLINE_CELL, ImageProtocol, InlineLayer},
Expand Down Expand Up @@ -483,8 +484,11 @@ pub struct App {
/// The system's settings with the user's choice for power saving applied.
pub settings: Settings,
settings_checked: Instant,
/// Where the palette comes from; `None` in tests, which keep cloofy's own colors.
colors: Option<Colors>,
pub accent: Accent,
/// The color of the playing cover, for when the accent follows it.
/// The dominant color of the playing cover, for when the accent follows it; tuned to the
/// background when shown.
cover_accent: Option<Rgb>,
pub me: Option<User>,
pub playlists: Vec<PlaylistInfo>,
Expand Down Expand Up @@ -605,8 +609,13 @@ impl App {
paths: Paths,
media: Option<cloofy_os::media::Controls>,
notifier: Option<Notifier>,
mut colors: Option<Colors>,
) -> Self {
let system_settings = system_settings();
// The palette from the first frame on, and the accent the app starts with.
if let Some(palette) = colors.as_mut().and_then(Colors::poll) {
theme::set_palette(palette);
}
let mut accent = Accent::new();
if let Some(color) = prefs.accent.fixed() {
accent.jump(color);
Expand Down Expand Up @@ -656,6 +665,7 @@ impl App {
slept_at: None,
system_settings,
settings_checked: Instant::now(),
colors,
accent,
cover_accent: None,
me: None,
Expand Down Expand Up @@ -1477,13 +1487,9 @@ impl App {
if let Some(old) = self.now.cover.replace(Cover { url, picture }) {
self.terminal_out.extend(old.picture.terminal_delete());
}
self.cover_accent = Some(accent);
self.cover_accent = accent;
if self.prefs.accent == AccentChoice::Cover {
if self.settings.low_power {
self.accent.jump(accent);
} else {
self.accent.set(accent);
}
self.show_accent();
}
}
Err(err) => tracing::warn!("cover {url}: {err}"),
Expand Down
30 changes: 23 additions & 7 deletions crates/cloofy-tui/src/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crossterm::event::{KeyCode, KeyEvent};
use super::{App, COVER_SIZE, Focus, ImageSlot};
use crate::{
backend,
colors::Colors,
commands::Command,
preferences::{AccentChoice, Setting},
theme,
Expand Down Expand Up @@ -88,6 +89,12 @@ impl App {
}
Setting::Covers => self.drop_covers(),
Setting::Images => self.set_image_protocol(self.prefs.images),
Setting::Colors => {
if let Some(colors) = &mut self.colors {
colors.set_choice(self.prefs.colors);
}
self.poll_colors();
}
Setting::Accent => self.show_accent(),
Setting::Icons => crate::icons::init(self.prefs.icons.config()),
Setting::PowerSaving => self.settings = self.prefs.apply(self.system_settings),
Expand All @@ -101,22 +108,31 @@ impl App {
self.save_setting(setting);
}

/// Moves the accent to the color the setting, the cover or the palette gives it now.
fn show_accent(&mut self) {
let color = self.prefs.accent.fixed().or(self.cover_accent).unwrap_or(theme::palette().accent);
/// Moves the accent to the color the setting, the cover or the palette gives it now. The
/// cover's is tuned to the background here, so it follows a change of colors.
pub(super) fn show_accent(&mut self) {
let cover = self.cover_accent.map(theme::cover_accent);
let color = self.prefs.accent.fixed().or(cover).unwrap_or(theme::palette().accent);
if self.settings.low_power {
self.accent.jump(color);
} else {
self.accent.set(color);
}
}

/// Draws with the system theme's `palette` from the next frame on. The accent goes along
/// where it comes from the palette, and the fixed ones adapt to a light background.
#[cfg(target_os = "linux")]
pub fn set_palette(&mut self, palette: theme::Palette) {
/// Draws with new colors from the next frame on when they changed, by the setting, Omarchy's
/// theme or `theme.toml`. The accent goes along where it comes from the palette, and the
/// fixed ones adapt to a light background. Returns whether the colors changed.
pub fn poll_colors(&mut self) -> bool {
let Some(palette) = self.colors.as_mut().and_then(Colors::poll) else { return false };
theme::set_palette(palette);
self.show_accent();
true
}

/// Whether the terminal told its colors, for the Terminal choice.
pub fn knows_terminal_colors(&self) -> bool {
self.colors.as_ref().is_some_and(Colors::knows_terminal)
}

/// Writes `setting` to the config file. The demo keeps changes until it closes.
Expand Down
Loading
Loading