Skip to content
Closed
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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,38 @@ jobs:
key: ${{ matrix.id }}
- run: cargo clippy --workspace --all-targets --locked ${{ matrix.features }} -- -D warnings

# Windows, where mpv's IPC runs over a named pipe instead of a socket pair. aws-lc-rs builds its
# assembly with NASM, through CMake; mpv itself plays the player's tests, which skip elsewhere.
windows:
name: Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
submodules: true
- uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable
with:
toolchain: stable
components: clippy
- name: Install NASM
run: |
choco install nasm --no-progress -y
echo "C:\Program Files\NASM" >> "$env:GITHUB_PATH"
- name: Install mpv
run: |
choco install mpv --no-progress -y
echo "C:\ProgramData\chocolatey\bin" >> "$env:GITHUB_PATH"
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2
with:
key: windows
- run: cargo build --locked -p cloofy --no-default-features --features ytmusic
- run: cargo build --locked -p cloofy --no-default-features --features spotify
- run: cargo clippy --workspace --all-targets --locked -- -D warnings
- run: cargo test --workspace --locked
env:
CLOOFY_REQUIRE_MPV: 1

# The oldest Rust that builds cloofy from source, as Cargo.toml's rust-version says.
msrv:
name: rust-version
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to cloofy. The format follows [Keep a Changelog](https://kee

## [Unreleased]

### Added

- **Windows.** cloofy builds and runs on Windows now: YouTube Music with mpv, Spotify, media keys and the system's Now Playing panel, sleep and wake, low power mode, toasts with the cover, and sign-ins in Credential Manager. `cloofy windows install` puts cloofy in the Start Menu, which Windows needs for notifications; `packaging/windows/install.ps1` builds and installs it. There is no Windows release to download yet, so updates say to build it here, and `cloofy login ytmusic` lists the browsers instead of guessing the default one.

## [0.5.3] - 2026-11-12

What you asked for: every song at the same loudness, shelves you can hide, cloofy in the app menu on Linux, and a YouTube Music sign-in that lasts.
Expand Down
62 changes: 58 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ zeno = "0.3"
# unixexec: zbus 5 always had it, for session buses reached through a command.
zbus = { version = "6", default-features = false, features = ["proxy", "service", "tokio", "unixexec"] }

# Windows bindings; each crate turns on the parts it uses.
windows = { version = "0.62", default-features = false }
# What `windows` hands back from an asynchronous WinRT call, such as writing a cover into a
# stream.
windows-future = "0.3"

# vendor/ holds forks as git submodules, both on branch `cloofy`:
# - librespot (github.com/parda21/librespot) with two open upstream PRs merged, DJ with
# narration (librespot-org/librespot#1797) and crossfade (#1756), plus fixes on top.
Expand Down
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,22 @@ YouTube Music needs no headers to build, and [mpv](https://mpv.io), [yt-dlp](htt

</details>

### Windows

Windows builds from source: Rust 1.90 or newer, plus CMake and NASM for Spotify's audio.

```powershell
cargo build --release --no-default-features --features ytmusic # or --features spotify, or both
```

`packaging/windows/install.ps1` builds it, copies it to `%LOCALAPPDATA%\cloofy\bin` and puts cloofy in the Start Menu, which is what lets Windows show its notifications; `-AddToPath` puts that folder on your `PATH` as well. `uninstall.ps1` takes the folder and that one entry out again, and `cloofy windows remove` only the Start Menu shortcut. `cloofy windows status` shows whether it is there.

YouTube Music needs [mpv](https://mpv.io), [yt-dlp](https://github.com/yt-dlp/yt-dlp) and [deno](https://deno.com) on `PATH`; [scoop](https://scoop.sh) has all three.

Covers are block art unless your terminal does Sixel: Windows Terminal 1.22 or newer does, and `images = "sixel"` in `config.toml` forces it.

Three things differ on Windows. Releases have no Windows build yet, so the update button says **update by building it here** instead of downloading. `cloofy login ytmusic` lists the browsers that have a profile instead of guessing the default one, which cloofy doesn't read from the registry. And plugging in headphones or switching the default output doesn't pause playback. `packaging/windows/README.md` lists what to check by hand.

## Setup

Set up the services you installed; the installer does it with you. With both, `cloofy login` signs in to each in turn, and asks before YouTube Music, which plays without an account.
Expand Down Expand Up @@ -269,10 +285,10 @@ On [Omarchy](https://omarchy.org), cloofy takes its colors from the theme and fo
| Ghostty, kitty, WezTerm | Real images | Built in | Yes |
| iTerm2 | Real images | With a Nerd Font | Yes |
| foot, Konsole, VS Code, xterm, mlterm | Real images | With a Nerd Font | On Linux |
| Windows Terminal | Real images | With a Nerd Font | No |
| Windows Terminal | Real images | With a Nerd Font | Yes |
| Others | Real images with Sixel, else blocks | With a Nerd Font | On Linux |

Every terminal needs true color. Without a Nerd Font, pick text icons in Settings. VS Code shows images once `terminal.integrated.enableImages` is on, xterm when started with `-ti 340`, and Windows Terminal from version 1.22. Inside tmux, covers are real images in Ghostty and kitty and blocks elsewhere, because tmux keeps only a few Sixel images at a time. On Linux, terminals without notifications of their own get them from the desktop, with the cover, and on Hyprland and Omarchy every terminal does.
Every terminal needs true color. Without a Nerd Font, pick text icons in Settings. VS Code shows images once `terminal.integrated.enableImages` is on, xterm when started with `-ti 340`, and Windows Terminal from version 1.22. Inside tmux, covers are real images in Ghostty and kitty and blocks elsewhere, because tmux keeps only a few Sixel images at a time. On Linux, terminals without notifications of their own get them from the desktop, with the cover, and on Hyprland and Omarchy every terminal does. On Windows they come from the desktop too, as toasts, which need the Start Menu shortcut `cloofy windows install` makes.

## FAQ

Expand Down
7 changes: 5 additions & 2 deletions crates/cloofy-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Config {
match self.credentials.as_deref() {
None | Some("files") => Ok(false),
Some("keychain") if cloofy_os::secrets::available() => Ok(true),
Some("keychain") => bail!("credentials = \"keychain\" works on macOS only for now"),
Some("keychain") => bail!("credentials = \"keychain\" works on macOS and Windows only for now"),
Some(other) => bail!("credentials = \"{other}\" is unknown: use \"keychain\" or \"files\""),
}
}
Expand Down Expand Up @@ -140,7 +140,10 @@ mod tests {
fn keeps_sign_ins_in_files_unless_asked() {
assert!(!credentials(None).keychain().unwrap());
assert!(!credentials(Some("files")).keychain().unwrap());
assert_eq!(credentials(Some("keychain")).keychain().is_ok(), cfg!(target_os = "macos"));
assert_eq!(
credentials(Some("keychain")).keychain().is_ok(),
cfg!(any(target_os = "macos", target_os = "windows"))
);
assert!(credentials(Some("vault")).keychain().is_err());
}

Expand Down
35 changes: 32 additions & 3 deletions crates/cloofy-core/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ impl Secret {
Secret::Keychain { name, file } => {
// A file wins: it was written by a login, or before the switch to the keychain.
if let Some(bytes) = read_file(file)? {
cloofy_os::secrets::set(name, &bytes).context("Saving to the keychain failed")?;
match cloofy_os::secrets::set(name, &bytes) {
// Too long for the keychain: the file is where it stays.
Err(err) if err.kind() == io::ErrorKind::InvalidInput => return Ok(Some(bytes)),
result => result.context("Saving to the keychain failed")?,
}
fs::remove_file(file).with_context(|| format!("{} can't be removed", file.display()))?;
return Ok(Some(bytes));
}
Expand All @@ -119,8 +123,15 @@ impl Secret {
Secret::File(path) => {
write_private(path, bytes).with_context(|| format!("{} is not writable", path.display()))
}
Secret::Keychain { name, .. } => {
cloofy_os::secrets::set(name, bytes).context("Saving to the keychain failed")
Secret::Keychain { name, file } => {
match cloofy_os::secrets::set(name, bytes) {
// Credential Manager holds 2560 bytes at most, and YouTube Music's cookies are
// longer: such a secret lives in the file the keychain would have replaced.
Err(err) if err.kind() == io::ErrorKind::InvalidInput => {
write_private(file, bytes).with_context(|| format!("{} is not writable", file.display()))
}
result => result.context("Saving to the keychain failed"),
}
}
}
}
Expand Down Expand Up @@ -197,6 +208,24 @@ mod tests {
fs::remove_dir_all(dir).unwrap();
}

/// Credential Manager holds 2560 bytes at most, and YouTube Music's cookies are longer: such
/// a secret stays in a file. Uses no keychain entry, as the store refuses it before writing.
#[cfg(target_os = "windows")]
#[test]
fn keeps_a_secret_too_long_for_the_keychain_in_a_file() {
let dir = scratch("keychain-too-long");
let name: &'static str = format!("test-{}", std::process::id()).leak();
let file = dir.join("cookies.txt");
let secret = Secret::Keychain { name, file: file.clone() };
let cookies = vec![b'x'; 3000];
secret.write(&cookies).unwrap();
assert_eq!(fs::read(&file).unwrap(), cookies, "it goes straight to the file");
assert_eq!(secret.read().unwrap().as_deref(), Some(&cookies[..]), "and reads back");
assert!(file.exists(), "reading leaves it there, as it can't move");
secret.delete().unwrap();
fs::remove_dir_all(dir).unwrap();
}

/// Writes to the login keychain: run it by hand with
/// `cargo test -p cloofy-core -- --ignored`.
#[test]
Expand Down
14 changes: 14 additions & 0 deletions crates/cloofy-core/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ fn target() -> Option<&'static str> {
})
}

/// Whether a release has a build for this machine, and so updates can put it in place of the
/// running binary. Where there is none, such as Windows so far, the interface says how to update
/// instead of offering to.
pub fn supported() -> bool {
target().is_some()
}

/// The release archive of the `variant` build for `target`. Each variant has the services it is
/// named after: `spotify`, `ytmusic`, or both in `full`.
fn archive_name(variant: &str, target: &str) -> String {
Expand Down Expand Up @@ -342,6 +349,13 @@ mod tests {
assert_eq!(of("/usr/bin-old/cloofy"), None);
}

/// Windows has no prebuilt build yet, so cloofy says how to update rather than offering to.
#[cfg(target_os = "windows")]
#[test]
fn has_no_release_to_update_to() {
assert!(!supported());
}

#[test]
fn homebrew_upgrades_the_formula_of_the_build() {
let brew = |variant| PackageManager::Homebrew.how_to_update(variant);
Expand Down
16 changes: 16 additions & 0 deletions crates/cloofy-os/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ tokio.workspace = true
url.workspace = true
zbus.workspace = true

[target.'cfg(windows)'.dependencies]
windows = { workspace = true, features = [
"Data_Xml_Dom",
"Foundation",
"Media",
"Media_Playback",
"Storage_Streams",
"UI_Notifications",
"Win32_Foundation",
"Win32_Security_Credentials",
"Win32_System_Power",
"Win32_System_WinRT",
"Win32_UI_WindowsAndMessaging",
] }
windows-future.workspace = true

[[test]]
name = "run_main"
harness = false
10 changes: 6 additions & 4 deletions crates/cloofy-os/src/fallback.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Systems without an integration yet: nothing to set up, nothing shown. Linux uses the parts it
//! has nothing better for.
//! has nothing better for, Windows only the audio.

#[cfg(not(target_os = "windows"))]
pub fn run_main<R>(work: impl FnOnce() -> R) -> R {
work()
}
Expand All @@ -18,7 +19,7 @@ pub mod audio {
}
}

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
pub mod power {
use std::sync::Arc;

Expand All @@ -29,7 +30,7 @@ pub mod power {
}
}

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
pub mod settings {
use crate::settings::Settings;

Expand All @@ -38,6 +39,7 @@ pub mod settings {
}
}

#[cfg(not(target_os = "windows"))]
pub mod secrets {
use std::io;

Expand All @@ -60,7 +62,7 @@ pub mod secrets {
}
}

#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "windows")))]
pub mod media {
use std::sync::Arc;

Expand Down
Loading