diff --git a/.gitignore b/.gitignore index d9e8b82..d62cb08 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ .DS_Store /design/shots .env +/packaging/arch/src +/packaging/arch/pkg +/packaging/arch/musyx +/packaging/arch/*.pkg.tar.* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6bef991 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Yuriy Panov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 3f13b72..5728a27 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,34 @@ This builds a release `Musyx.app` into `target/release/bundle/`, signed with the `MUSYX_SIGN_IDENTITY` to sign with another identity, or to `-` for an ad-hoc signature (each ad-hoc build is a new code identity, so macOS asks again for keychain access). +## Install on Linux + +```sh +tool/bundle-linux.sh # tarball, .deb and AppImage into target/release/bundle/ +tool/bundle-linux.sh tar deb # only the formats named +tool/bundle-linux.sh --install # install into ~/.local (PREFIX picks another prefix) +``` + +On Arch, `makepkg -si` in `packaging/arch` builds and installs the committed `HEAD`. + +Building needs `pkg-config` and the ALSA and D-Bus development files (`alsa-lib` and `dbus` +on Arch, `libasound2-dev` and `libdbus-1-dev` on Debian/Ubuntu). The AppImage also needs +[`appimagetool`](https://github.com/AppImage/appimagetool/releases) on `PATH` (or +`APPIMAGETOOL`). A binary runs only on a glibc at least as new as the one it was built +against, so build release packages on the oldest distro you want to support. + +The desktop entry, metainfo and icons are installed as `it.panov.musyx.desktop`, which is also the +window's Wayland app id. The token goes to the Secret Service (GNOME Keyring, KWallet, +KeePassXC), and media keys and the desktop's player widget work through MPRIS. The menu bar +mini player is macOS-only. + ## Settings Settings (streaming quality, appearance, language, volume) are kept in -`~/Library/Application Support/Musyx/settings.json`. Covers are cached under -`~/Library/Caches/Musyx/covers` and can be cleared from Settings. +`~/Library/Application Support/Musyx/settings.json` on macOS and +`~/.config/musyx/settings.json` on Linux. Covers are cached under +`~/Library/Caches/Musyx/covers` (`~/.cache/musyx/covers` on Linux) and can be cleared from +Settings. Streaming quality **Lossless** asks Yandex for FLAC (through the signed `/get-file-info` endpoint, decrypting its AES-CTR stream in memory). Yandex decides what to grant by diff --git a/crates/musyx/src/main.rs b/crates/musyx/src/main.rs index f1304f1..a7c8628 100644 --- a/crates/musyx/src/main.rs +++ b/crates/musyx/src/main.rs @@ -18,6 +18,10 @@ use iced::{Size, window}; use app::App; use ui::theme; +/// The Linux application id: the window's Wayland app id / X11 class and the `.desktop` name. +#[cfg(target_os = "linux")] +const APP_ID: &str = "it.panov.musyx.desktop"; + fn main() -> iced::Result { let app = iced::application(App::new, App::update, App::view) .title(App::title) @@ -28,6 +32,12 @@ fn main() -> iced::Result { size: Size::new(1280.0, 800.0), min_size: Some(Size::new(960.0, 620.0)), icon: window::icon::from_file_data(include_bytes!("../assets/icon/musyx.png"), None).ok(), + // Matches the installed `it.panov.musyx.desktop.desktop`, so the shell shows its name and icon. + #[cfg(target_os = "linux")] + platform_specific: window::settings::PlatformSpecific { + application_id: APP_ID.to_owned(), + ..Default::default() + }, ..window::Settings::default() }) .centered(); diff --git a/crates/musyx/src/menubar.rs b/crates/musyx/src/menubar.rs index 9493b03..23fc1b7 100644 --- a/crates/musyx/src/menubar.rs +++ b/crates/musyx/src/menubar.rs @@ -24,6 +24,7 @@ impl NowPlaying { }) } + #[cfg(any(target_os = "macos", test))] fn line(&self) -> String { if self.artist.is_empty() { self.title.clone() } else { format!("{} — {}", self.title, self.artist) } } diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD new file mode 100644 index 0000000..2025689 --- /dev/null +++ b/packaging/arch/PKGBUILD @@ -0,0 +1,56 @@ +# Maintainer: Yuriy Panov +# Builds the checked-out commit of this repository: run `makepkg -si` in this directory. +pkgname=musyx +pkgver=0.2.0 +pkgrel=1 +pkgdesc='Desktop player for Yandex Music (unofficial)' +arch=('x86_64' 'aarch64') +license=('MIT' 'OFL-1.1' 'ISC') +depends=('alsa-lib' 'dbus' 'gcc-libs' 'glibc' 'libxkbcommon' 'wayland' 'hicolor-icon-theme') +optdepends=('gnome-keyring: keeps the sign-in (any Secret Service provider works)' + 'vulkan-driver: GPU rendering') +makedepends=('cargo' 'git' 'imagemagick') +options=('!lto' '!debug') +source=("$pkgname::git+file://${startdir%/packaging/arch}") +sha256sums=('SKIP') + +app_id=it.panov.musyx.desktop + +pkgver() { + cd "$pkgname" + sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1 +} + +prepare() { + cd "$pkgname" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')" +} + +build() { + cd "$pkgname" + export RUSTUP_TOOLCHAIN=stable CARGO_TARGET_DIR=target + cargo build --frozen --release -p musyx +} + +check() { + cd "$pkgname" + export RUSTUP_TOOLCHAIN=stable CARGO_TARGET_DIR=target + cargo test --frozen --release --workspace +} + +package() { + cd "$pkgname" + install -Dm755 target/release/musyx "$pkgdir/usr/bin/musyx" + install -Dm644 "packaging/linux/$app_id.desktop" "$pkgdir/usr/share/applications/$app_id.desktop" + install -Dm644 "packaging/linux/$app_id.metainfo.xml" "$pkgdir/usr/share/metainfo/$app_id.metainfo.xml" + for size in 16 32 48 64 128 256 512; do + install -dm755 "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps" + magick crates/musyx/assets/icon/musyx.png -resize "${size}x${size}" \ + "$pkgdir/usr/share/icons/hicolor/${size}x${size}/apps/$app_id.png" + done + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + install -Dm644 crates/musyx/assets/fonts/OFL-*.txt -t "$pkgdir/usr/share/licenses/$pkgname" + install -Dm644 crates/musyx/assets/icons/LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE-lucide.txt" + install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md" +} diff --git a/packaging/linux/it.panov.musyx.desktop.desktop b/packaging/linux/it.panov.musyx.desktop.desktop new file mode 100644 index 0000000..b5880c6 --- /dev/null +++ b/packaging/linux/it.panov.musyx.desktop.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Type=Application +Name=Musyx +GenericName=Music Player +GenericName[ru]=Музыкальный проигрыватель +Comment=Desktop player for Yandex Music +Comment[ru]=Настольный проигрыватель для Яндекс Музыки +Exec=musyx +Icon=it.panov.musyx.desktop +Terminal=false +Categories=AudioVideo;Audio;Player; +Keywords=music;yandex;player;audio; +Keywords[ru]=музыка;яндекс;плеер;аудио; +StartupWMClass=it.panov.musyx.desktop +SingleMainWindow=true diff --git a/packaging/linux/it.panov.musyx.desktop.metainfo.xml b/packaging/linux/it.panov.musyx.desktop.metainfo.xml new file mode 100644 index 0000000..8bb3ba7 --- /dev/null +++ b/packaging/linux/it.panov.musyx.desktop.metainfo.xml @@ -0,0 +1,28 @@ + + + it.panov.musyx.desktop + Musyx + Desktop player for Yandex Music + Настольный проигрыватель для Яндекс Музыки + MIT + MIT + + Yuriy Panov + + +

+ An unofficial client for Yandex Music: My Wave, search, your collection, podcasts, + lyrics and lossless streaming. Not affiliated with or endorsed by Yandex. +

+
+ it.panov.musyx.desktop.desktop + + AudioVideo + Audio + Player + + + + + +
diff --git a/tool/bundle-linux.sh b/tool/bundle-linux.sh new file mode 100755 index 0000000..21d5158 --- /dev/null +++ b/tool/bundle-linux.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +# Builds Linux release packages into target/release/bundle/. +# tool/bundle-linux.sh # tarball, .deb and AppImage +# tool/bundle-linux.sh tar deb # only the formats named (tar, deb, appimage) +# tool/bundle-linux.sh --install # build, then install into ~/.local +# The Arch package lives in packaging/arch (makepkg there). +# The AppImage needs appimagetool on PATH, or APPIMAGETOOL pointing at it. +# Binaries need the glibc they were built against or newer, so build releases on the +# oldest distro you want to support (Ubuntu 22.04 covers most desktops). +set -euo pipefail + +root="$(cd "$(dirname "$0")/.." && pwd)" +cd "$root" + +formats=() +install=0 +for arg in "$@"; do + case "$arg" in + tar | deb | appimage) formats+=("$arg") ;; + --install) install=1 ;; + *) echo "unknown argument: $arg" >&2; exit 2 ;; + esac +done +if [[ ${#formats[@]} -eq 0 && $install -eq 0 ]]; then + formats=(tar deb appimage) +fi + +app_id="it.panov.musyx.desktop" +version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" +arch="$(uname -m)" +case "$arch" in + x86_64) deb_arch=amd64 ;; + aarch64) deb_arch=arm64 ;; + *) deb_arch="$arch" ;; +esac +out="target/release/bundle" +work="$(mktemp -d)" +trap 'rm -rf "$work"' EXIT + +cargo build --release -p musyx + +# The installed layout, rooted at $1 (a prefix such as /usr): binary, desktop entry, +# AppStream metadata, hicolor icons and licences. +stage() { + local dest="$1" + install -Dm755 target/release/musyx "$dest/bin/musyx" + install -Dm644 "packaging/linux/$app_id.desktop" "$dest/share/applications/$app_id.desktop" + install -Dm644 "packaging/linux/$app_id.metainfo.xml" "$dest/share/metainfo/$app_id.metainfo.xml" + for size in 16 32 48 64 128 256 512; do + mkdir -p "$dest/share/icons/hicolor/${size}x${size}/apps" + magick crates/musyx/assets/icon/musyx.png -resize "${size}x${size}" \ + "$dest/share/icons/hicolor/${size}x${size}/apps/$app_id.png" + done + local doc="$dest/share/doc/musyx" + install -Dm644 LICENSE "$doc/LICENSE" + install -Dm644 README.md "$doc/README.md" + install -Dm644 crates/musyx/assets/fonts/OFL-*.txt -t "$doc" + install -Dm644 crates/musyx/assets/icons/LICENSE.txt "$doc/LICENSE-lucide.txt" +} + +mkdir -p "$out" + +if [[ $install -eq 1 ]]; then + prefix="${PREFIX:-$HOME/.local}" + stage "$prefix" + update-desktop-database "$prefix/share/applications" 2>/dev/null || true + gtk-update-icon-cache -q -t "$prefix/share/icons/hicolor" 2>/dev/null || true + echo "Installed musyx $version into $prefix" +fi + +for format in "${formats[@]}"; do + case "$format" in + tar) + # Unpack anywhere and run ./install.sh (to ~/.local, or PREFIX=/usr/local with sudo). + name="musyx-$version-linux-$arch" + dir="$work/$name" + stage "$dir/files" + cat > "$dir/install.sh" <<'SH' +#!/bin/sh +# Installs Musyx into $PREFIX (default ~/.local). Run with PREFIX=/usr/local as root for all users. +set -eu +prefix="${PREFIX:-$HOME/.local}" +here="$(cd "$(dirname "$0")" && pwd)" +mkdir -p "$prefix" +cp -R "$here/files/." "$prefix/" +update-desktop-database "$prefix/share/applications" 2>/dev/null || true +gtk-update-icon-cache -q -t "$prefix/share/icons/hicolor" 2>/dev/null || true +echo "Installed Musyx into $prefix" +SH + chmod 755 "$dir/install.sh" + tar -C "$work" -czf "$out/$name.tar.gz" "$name" + echo "Built $out/$name.tar.gz" + ;; + + deb) + # Assembled by hand (ar + tar), so dpkg-deb isn't needed on the build machine. + pkg="$work/deb" + stage "$pkg/usr" + installed_kb="$(du -sk "$pkg/usr" | cut -f1)" + mkdir -p "$pkg/DEBIAN" + cat > "$pkg/DEBIAN/control" < +Installed-Size: $installed_kb +Depends: libc6, libgcc-s1, libasound2t64 | libasound2, libdbus-1-3, libxkbcommon0, libwayland-client0 | libx11-6 +Recommends: gnome-keyring | kwalletmanager, libvulkan1 | libgl1 +Section: sound +Priority: optional +Description: Desktop player for Yandex Music + An unofficial client for Yandex Music: My Wave, search, your collection, + podcasts, lyrics and lossless streaming. Not affiliated with Yandex. +CONTROL + (cd "$pkg" && find usr -type f -exec md5sum {} + > DEBIAN/md5sums) + echo "2.0" > "$work/debian-binary" + tar -C "$pkg/DEBIAN" --owner=0 --group=0 -cJf "$work/control.tar.xz" . + tar -C "$pkg" --owner=0 --group=0 --exclude=./DEBIAN -cJf "$work/data.tar.xz" . + deb="$out/musyx_${version}_${deb_arch}.deb" + rm -f "$deb" + (cd "$work" && ar rc "$root/$deb" debian-binary control.tar.xz data.tar.xz) + echo "Built $deb" + ;; + + appimage) + tool="${APPIMAGETOOL:-$(command -v appimagetool || true)}" + if [[ -z "$tool" ]]; then + echo "appimagetool not found: put it on PATH or set APPIMAGETOOL" >&2 + echo " (https://github.com/AppImage/appimagetool/releases)" >&2 + exit 1 + fi + appdir="$work/Musyx.AppDir" + stage "$appdir/usr" + ln -s usr/bin/musyx "$appdir/AppRun" + cp "packaging/linux/$app_id.desktop" "$appdir/$app_id.desktop" + cp "$appdir/usr/share/icons/hicolor/256x256/apps/$app_id.png" "$appdir/$app_id.png" + ln -s "$app_id.png" "$appdir/.DirIcon" + image="$out/Musyx-$version-$arch.AppImage" + ARCH="$arch" "$tool" --no-appstream "$appdir" "$image" >/dev/null + echo "Built $image" + ;; + esac +done diff --git a/tool/bundle-macos.sh b/tool/bundle-macos.sh index 839a1f1..598d5c7 100755 --- a/tool/bundle-macos.sh +++ b/tool/bundle-macos.sh @@ -36,7 +36,7 @@ cat > "$bundle/Contents/Info.plist" < CFBundleNameMusyx CFBundleDisplayNameMusyx - CFBundleIdentifierdev.musyx.desktop + CFBundleIdentifierit.panov.musyx.desktop CFBundleDevelopmentRegionen CFBundleLocalizationsenru CFBundleExecutableMusyx