feat: media keys, device recovery, settings and a macOS app bundle

- Media keys and Now Playing (souvlaki): title, artist, album, cover and
  position published on track and state changes; play/pause/toggle,
  next/previous and seeking from the OS controls
- Audio engine reopens the default output when the device changes or
  disappears, reloading the current track at the same position; with no
  device it keeps looking and resumes when one appears. Underruns are
  ignored rather than treated as device loss
- Settings screen: streaming quality (Best, Balanced <=192 kbps, Data
  saver <=128 kbps), appearance (system/light/dark), clear cover cache;
  quality, appearance and volume persist as JSON in the config folder
- Bitrate cap chooses the best variant within it, or the smallest above
- Lyrics failures get a retry button
- App icon drawn by tool/make_icon.py; tool/bundle-macos.sh builds an
  ad-hoc signed Musyx.app (--install copies it to /Applications)
- Release profile: thin LTO and stripped symbols
This commit is contained in:
Yuriy Panov committed 2026-10-15 16:28:07 +06:00
1 parent e2312f2d40
commit 60156aba94
19 files changed
+1039 -94

No files matched your search

+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# Builds Musyx.app (release, ad-hoc signed) into target/release/bundle/.
# tool/bundle-macos.sh # build the bundle
# tool/bundle-macos.sh --install # and copy it to /Applications
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
cd "$root"
version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
bundle="target/release/bundle/Musyx.app"
cargo build --release -p musyx
rm -rf "$bundle"
mkdir -p "$bundle/Contents/MacOS" "$bundle/Contents/Resources"
cp target/release/musyx "$bundle/Contents/MacOS/Musyx"
# Icon: every size macOS asks for, from the 1024px master.
iconset="$(mktemp -d)/Musyx.iconset"
mkdir -p "$iconset"
master="crates/musyx/assets/icon/musyx.png"
for size in 16 32 128 256 512; do
sips -z "$size" "$size" "$master" --out "$iconset/icon_${size}x${size}.png" >/dev/null
double=$((size * 2))
sips -z "$double" "$double" "$master" --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$iconset" -o "$bundle/Contents/Resources/Musyx.icns"
cat > "$bundle/Contents/Info.plist" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>Musyx</string>
<key>CFBundleDisplayName</key><string>Musyx</string>
<key>CFBundleIdentifier</key><string>dev.musyx.desktop</string>
<key>CFBundleExecutable</key><string>Musyx</string>
<key>CFBundleIconFile</key><string>Musyx</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>${version}</string>
<key>CFBundleVersion</key><string>${version}</string>
<key>LSMinimumSystemVersion</key><string>11.0</string>
<key>LSApplicationCategoryType</key><string>public.app-category.music</string>
<key>NSHighResolutionCapable</key><true/>
<key>NSHumanReadableCopyright</key><string>Unofficial Yandex Music client. Not affiliated with Yandex.</string>
</dict>
</plist>
PLIST
# Ad-hoc signature: enough to run locally. Each new build is a new identity to the
# keychain, so macOS may ask once to allow access to the saved sign-in.
codesign --force --deep --sign - "$bundle"
echo "Built $bundle ($version)"
if [[ "${1:-}" == "--install" ]]; then
rm -rf "/Applications/Musyx.app"
cp -R "$bundle" /Applications/
echo "Installed /Applications/Musyx.app"
fi
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
"""Draws the Musyx app icon (1024x1024 PNG) with no dependencies.
Aubergine squircle with amber wave lines, matching the My Wave hero.
Usage: python3 tool/make_icon.py crates/musyx/assets/icon/musyx.png
"""
import math
import struct
import sys
import zlib
SIZE = 1024
# macOS icon grid: the body is 824px, centred, with a ~185px corner radius.
BODY, RADIUS = 824, 185
OFF = (SIZE - BODY) / 2
TOP, BOTTOM = (0x35, 0x30, 0x42), (0x1C, 0x1A, 0x22)
AMBER = (0xF0, 0xB2, 0x3E)
LINES = 11
def rounded_alpha(x, y):
"""Coverage of the rounded square at pixel centre (x, y), anti-aliased."""
px, py = x + 0.5 - OFF, y + 0.5 - OFF
cx = min(max(px, RADIUS), BODY - RADIUS)
cy = min(max(py, RADIUS), BODY - RADIUS)
d = math.hypot(px - cx, py - cy) - RADIUS
if px < 0 or py < 0 or px > BODY or py > BODY:
d = max(d, 1.0)
return min(max(0.5 - d, 0.0), 1.0)
def wave(k, x):
"""Height of line k at x, and its slope, in pixels."""
u = (x - OFF) / BODY
base = OFF + BODY * (0.34 + k * 0.034)
amp = BODY * (0.045 + k * 0.006)
f = 1.5 + k * 0.08
ph = k * 0.55 + 1.1
a = u * math.pi * f + ph
b = u * math.pi * 4.2 - ph * 0.7
y = base + math.sin(a) * amp + math.sin(b) * amp * 0.35
dy = (math.cos(a) * amp * math.pi * f + math.cos(b) * amp * 0.35 * math.pi * 4.2) / BODY
return y, dy
def main(out):
rows = []
curves = [[wave(k, x + 0.5) for x in range(SIZE)] for k in range(LINES)]
for y in range(SIZE):
row = bytearray([0]) # filter: none
t = y / SIZE
bg = tuple(round(TOP[i] + (BOTTOM[i] - TOP[i]) * t) for i in range(3))
for x in range(SIZE):
cover = rounded_alpha(x, y)
if cover == 0.0:
row += b"\x00\x00\x00\x00"
continue
r, g, b = bg
for k in range(LINES):
cy, slope = curves[k][x]
dist = abs(y + 0.5 - cy) / math.sqrt(1 + slope * slope)
width = 4.0 + k * 0.9
a = min(max(width / 2 - dist + 0.5, 0.0), 1.0)
if a:
a *= 0.18 + 0.82 * (k / (LINES - 1))
r = r + (AMBER[0] - r) * a
g = g + (AMBER[1] - g) * a
b = b + (AMBER[2] - b) * a
row += bytes((round(r), round(g), round(b), round(cover * 255)))
rows.append(bytes(row))
def chunk(kind, data):
return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data) & 0xFFFFFFFF)
png = b"\x89PNG\r\n\x1a\n"
png += chunk(b"IHDR", struct.pack(">IIBBBBB", SIZE, SIZE, 8, 6, 0, 0, 0))
png += chunk(b"IDAT", zlib.compress(b"".join(rows), 9))
png += chunk(b"IEND", b"")
with open(out, "wb") as f:
f.write(png)
if __name__ == "__main__":
main(sys.argv[1] if len(sys.argv) > 1 else "musyx.png")