Compare commits

...
36 Commits
Author SHA1 Message Date
Ansho Rei f6e303bd0f fix: give the window the app id so docks show the remus icon
Without an app id on Wayland, or a WM_CLASS on X11, a dock cannot link
the window to me.anshorei.Fettleshed.Remus.desktop and draws a generic
icon. The desktop file also names the class in StartupWMClass.
2026-11-07 03:34:28 +01:00
Ansho Rei d0f1b6c95a feat: add a Controls page and keep only contextual hints in the bar
Settings lists every button and key, grouped by where it works and drawn
for the controller in use or the keyboard. The controls bar drops what
works the same everywhere, such as Back, Play / Pause and Sections, so
the hints that depend on the selection are no longer pushed aside. The
login screen keeps all its hints, since Settings is out of reach there.

Bumps the version to 0.10.3.
2026-11-07 00:13:59 +01:00
Ansho Rei c6944041ea fix: release the screensaver when leaving the last server while playing
Leaving the browsed server for the login screen stopped the player but
never updated the screensaver inhibit, and stop_player drops the events
that would have. The playback reset from switch_server is now a helper
that also syncs the inhibit, used for both paths, so logging in again
starts without the old queue's pause, position or restore state.

Bumps the version to 0.10.2.
2026-11-06 23:44:50 +01:00
Ansho Rei f03374b585 feat: replace the login screen's Exit button with an X in the corner
The full-width button under Connect took a row in a card that is close
to filling an 800 px high screen. The X is a focus stop between the
saved servers and the address field, so Up from the address field still
reaches it from a controller.

Bumps the version to 0.10.1.
2026-11-06 23:35:37 +01:00
Ansho Rei 5bb42ba834 feat: log out of or forget a saved server, and pick one on the login screen
The queue button on a server row in Settings opens a prompt with Cancel,
Log out and Forget, replacing the double-press Remove. Log out keeps the
address and username without credentials; Forget also deletes the
server's saved queue and cover cache. The login screen lists the saved
servers beside the form, and a saved login the server turns down at
startup is logged out and opens the login screen prefilled.

Bumps the version to 0.10.0.
2026-11-06 23:34:30 +01:00
Ansho Rei 07214f1827 chore: bump the version to 0.9.1 for the fullscreen dev script steps 2026-11-06 20:28:50 +01:00
Ansho Rei 885ca01ff7 chore: drive and log the fullscreen toggle from the dev script
Adds a fullscreen step that runs the toggle action and a key:f11 step
that sends F11 through the Slint window, plus a debug log of the state
each toggle starts from. A scripted run could not reproduce F11 failing
to re-enter fullscreen on COSMIC, so the log is there for a manual run.
2026-11-06 20:27:29 +01:00
Ansho Rei 768ef0f919 chore: bump the version to 0.9.0 for shuffle 2026-11-05 19:29:17 +01:00
Ansho Rei 26d8bc417c feat: show the shuffle mode beside the queue on the now-playing screen
The hint bar names the mode too, but it can be turned off.
2026-11-05 19:22:54 +01:00
Ansho Rei 0200e73ba3 feat: shuffle the whole library from the Random section
Shuffle all, the first tile of the Random section, plays random tracks
from getRandomSongs and fetches another batch when fewer than five are
left. Played tracks past the last fifty are dropped, so the queue stays
small. Tracks queued meanwhile play after the playing track and after
anything queued before them, ahead of the random ones. Playing anything
else ends it, and it carries on after a restart.
2026-11-05 19:07:01 +01:00
Ansho Rei e11d95daa5 feat: shuffle play an album, artist or playlist with a long press
Holding South on a row, or shift+s on the keyboard, plays its tracks in
random order with track shuffle on, so turning shuffle off goes back to
their own order. On a song row it shuffles the page the song is on. An
artist plays every track of every album, fetched a few albums at a time.

South now acts on release, so a long press can mean something else. A
long press on a row with nothing to shuffle activates as before.
2026-11-05 19:04:08 +01:00
Ansho Rei 3d91739447 feat: cycle the queue through track shuffle, album shuffle and off
North on the now-playing screen, or s anywhere, shuffles what has not
played yet. Off goes back to the order the tracks were queued in and
carries on after the playing track. Tracks queued while shuffled go to
random positions, an album as one block under album shuffle.

The player reorders its own list under its lock and keeps a track it
already handed to playbin next, so playback stays gapless. Each reorder
bumps a queue generation that track and picture events carry, and the
app drops an event sent before the last reorder. The saved queue keeps
the original order and the mode; older files load unshuffled.
2026-11-05 18:57:56 +01:00
Ansho Rei 7b2fe7c84e feat: add track, album and insert shuffle orders
Each function returns positions in the new play order, so the queue,
the original order and the player's URLs can be reordered by the same
list. Nothing calls them yet.
2026-11-05 18:39:03 +01:00
Ansho Rei 10710c1755 feat: read a song's album id and fetch random songs from the server
Album shuffle groups tracks by album id, since the album name alone
merges different albums with the same title. Library shuffle tops up
the queue with getRandomSongs.
2026-11-05 18:39:03 +01:00
Ansho Rei bce0d68442 feat: show a track's own cover on its album page row
A track whose cover is a different picture from the album's now shows
that cover in its row instead of the track number. Pictures are compared
decoded, since Navidrome gives every track its own cover id even when it
is the album's image. The number column is as wide as the cover, so rows
with and without one line up.
2026-11-04 22:09:32 +01:00
Ansho Rei d77316b5b7 fix: delete covers cached before they were kept per server
Since 0.8.0 covers are cached in a directory per server. The files that
earlier versions wrote straight into the cache root were never read
again and never removed. They are now deleted once on start, in the
background; the server directories are left alone.
2026-11-04 21:35:04 +01:00
Ansho Rei 5b678d4f1c docs: say where the version shows while the controls bar is hidden
The README said the version is on every screen. Since the controls bar
can be turned off, it moves to a Version row in Settings instead.
2026-11-04 21:33:46 +01:00
Ansho Rei a005c3207a fix: ignore the controller while another window is in front
remus reads the controller from the device, whichever window has focus,
so presses meant for a game in front also skipped tracks and paused in
remus. It now follows winit's focus events, through slint's
unstable-winit-030 feature since Slint does not expose window activation
itself, and drops controller presses while the window is not in front.
It assumes focus until told otherwise, so a window manager that never
reports focus keeps the controller working.
2026-11-04 20:51:33 +01:00
Ansho Rei 6997e7cd93 fix: show the picture in the playing track's file on the now-playing screen
Nextcloud Music gives every song of an album the album's cover id, so
tracks with their own art all showed the album cover. The player now
reads the picture embedded in each file it decodes and reports it once
per track, or reports that there is none. The now-playing art, backdrop
and palette use it, and wait for that answer so they do not show the
album cover first and then change. Lists and the queue keep the
server's cover.

Pictures are read where each file's decoder hands on its stream:
further down, a file without a picture still carries the previous
file's tags after a gapless switch.
2026-11-04 20:22:03 +01:00
Ansho Rei b5ef9fbb13 fix: centre the play/pause icon and volume bar under the progress
The icon was centred in the space between the two times, so it moved
when their widths differed. The time row is now placed by hand: times
at the edges, icon on the row's midpoint.

The volume row was centred as a whole, and its number label is wider
than the speaker, so the bar sat left of centre. On now playing the
speaker now gets a box as wide as the label, which puts the bar in the
middle. The bottom bar keeps the compact layout.
2026-11-04 19:38:26 +01:00
Ansho Rei 3518462dde feat: show the password on the login screen on request
The password field has an eye at its right end that switches the field
between masked and plain text, struck through while the text shows. From
a controller, the queue button toggles it while the field is selected,
and the hint bar says so. A keyboard types into the field, so it uses
the eye instead. It is hidden again each time the login screen opens.
2026-11-04 19:06:11 +01:00
Ansho Rei d4de15acd8 feat: keep several logins and switch between them
config.toml now holds a list of [[server]] logins and the active one.
The single-login file of earlier versions loads as the only entry.

Settings lists the servers first: confirm switches, the queue button
pressed twice removes, and Add server opens the login form, which can
now be cancelled. Removing the last login returns to the login screen.

A switch saves the queue of the server being left, stops the player and
restores the other server's saved queue paused. Player events sent
before the stop are dropped by an epoch, and cover loads started for the
old server by a generation, so nothing of one server shows on the other.
Covers are cached on disk per server, keyed like the saved queue.

The shoulder triggers wrap around the sections, which puts Settings one
press from the first section.
2026-11-04 18:23:30 +01:00
Ansho Rei 0bcba21f1a feat: control playback through MPRIS
Remus owns org.mpris.MediaPlayer2.remus on the session bus and serves
the root and player interfaces: play, pause, play-pause, stop, next,
previous and quit, with the playback status, track metadata, position
and volume. Desktops route media keys to the active MPRIS player, and
headphone buttons arrive as media keys, so this is how they reach remus.

Reading the headphones' input devices directly was ruled out: keyboard
type devices, AVRCP included, are root:input, and only gamepads are
opened up to the logged-in user. Seeking is not offered (CanSeek false).

The Flatpak gets --own-name for the bus name.
2026-11-04 17:57:32 +01:00
Ansho Rei ab42814302 feat: add a setting to hide the controls bar
Settings has a Show controls bar toggle, on by default and saved as
show_hint_bar. Off, the hint bar goes from the browse and now-playing
screens and the content takes its height. The login screen keeps it,
since the controls are not known yet there and Settings is out of reach.

The bar is where the version shows, so while it is off Settings lists
the version instead.
2026-11-04 17:18:16 +01:00
Ansho Rei a5d51cf044 fix: place the volume level under the progress and in the bottom bar
On now playing it is centred under the progress bar. The bottom bar on
the other screens shows it too, at the right after the time and play
state. Its number has a fixed width: with only a minimum, the row gave
it the spare space and pushed the time into the middle.
2026-11-04 15:44:34 +01:00
Ansho Rei 0e7c63c09a feat: add volume control with the right stick and keys
Right stick up and down change the volume in steps of 5 and clicking it
mutes; + (or =), - and m do the same on a keyboard, on every screen. The
stick's dominant axis wins, so a diagonal push does not seek and change
the volume at once. Any step unmutes.

The level goes to playbin's volume on a cubic scale, so steps sound
even, and to its mute. A pill shows the level for a moment after each
change, the now-playing screen shows it under the times, and it is
saved in settings.toml once the changes stop and on quit.

Hint icons for the right stick and the keys are from Kenney's Input
Prompts 1.5, like the others.
2026-11-04 15:18:17 +01:00
Ansho Rei 5e1e120457 chore: keep downloads in an ignored .scratch directory
Ignored by git and skipped by the Flatpak build, so a fetched asset pack
such as Kenney's Input Prompts can stay around between sessions.
2026-11-04 15:18:17 +01:00
Ansho Rei 9be6f86557 feat: show play and pause icons instead of words on now playing
A PlayState component draws the triangle and the two bars as vectors in
the highlight colour. The mini player uses it too, in place of the ▶
and ❚❚ glyphs, which a font fallback could draw as emoji or at
different weights.
2026-11-04 14:40:50 +01:00
Ansho Rei 341ae614e1 feat: add a cover backdrop slider to the settings
The first range setting: its row draws a slider, and left and right
change it in steps of 10 while confirm still flips the toggles. Saved
as cover_backdrop in settings.toml, defaulting to the old fixed look.

Up to the default the cover fades in under the old overlay. Above it
the overlay thins as well, down to 0.55 on the left where the title and
progress sit, which kept them readable over a bright cover.
2026-11-04 14:31:17 +01:00
Ansho Rei 2e8b2e6a02 feat: flip the now-playing cover when the picture changes
The cover turns edge-on, swaps, and turns back with an overshooting
curve. Slint has no perspective, so the turn squashes the width.

Whether to flip is decided by a hash of the decoded pixels, not by the
cover id: Navidrome gives every track its own id even when the whole
album shares one image. While the new cover loads the old one stays up,
and the next track's cover is fetched ahead so a skip decides at once.
2026-11-04 13:44:38 +01:00
Ansho Rei 578a4f5607 fix: enlarge the app icon's mark so it reads at small sizes
The tile now starts 2 units from the edge instead of 8 and the mark is
100 tall instead of 74, nudged up 1 unit because its base reads heavier
than the R.
2026-11-04 13:06:36 +01:00
Ansho Rei d90191618d fix: centre the logo on the login screen 2026-11-04 13:05:46 +01:00
Ansho Rei 936e28b483 feat: add an Exit button to the login screen
The login screen could only be left with Ctrl+Q, which a gamepad cannot
press. Exit sits below Connect as the last focus stop and goes through
Action::Quit.
2026-11-04 13:05:45 +01:00
Ansho Rei 62169be746 feat: keep the screensaver off while music is playing
Holds org.freedesktop.ScreenSaver.Inhibit, the call Electron apps
such as VacuumTube use to stay awake in Steam's Game Mode, and the
XDG portal's idle inhibit, from play until pause, stop or quit.
zbus 6 cannot connect through Flatpak's D-Bus proxy, so this uses
zbus 5.
2026-11-04 12:57:14 +01:00
Ansho Rei 5a2386e817 build: add make publish to release a version on Gitea with its bundle
Releases on Gitea had nothing to install, so getting remus onto a Steam
machine meant building the bundle and copying it across by hand. After
a bump and a push with tags, make publish builds the Flatpak bundle for
the tagged commit and creates the release, with the changelog entry as
its notes and remus-X.Y.Z.flatpak attached.

Every check runs before the slow build: a clean tree, HEAD tagged with
the Cargo.toml version, a token, the same tag on the remote and no
release for it yet. The token is read from GITEA_TOKEN or
~/.config/gitea/token and passed to curl in a header file, so it is
never on a command line. If the upload fails, the release is deleted
so the next run starts clean.
2026-11-04 11:25:32 +01:00
Ansho Rei e915d00226 feat: restore the queue and position after a restart
Quitting, a crash or SteamOS restarting the app lost the queue and how
far into the track playback was, which hurts most for long items. The
queue is now saved to queue.json in the state directory, one queue per
user and server, on a track change, on pause, when songs are queued,
every 15 seconds while playing and on quit. It holds song metadata,
never a stream URL, since those carry the token or the password.

On start the saved track is loaded paused and seeked to once it has
prerolled. Nothing plays, and the server is not told about the track,
until play is pressed. An unreadable file is logged and ignored.

Two player bugs had to go for this. A failing source posts several
errors, and the later ones counted against the next track, so one
missing song skipped two tracks or stopped the queue. Play pressed
while a track was still loading was dropped.
2026-11-04 11:23:31 +01:00
44 changed files with 5359 additions and 265 deletions
+1
View File
@@ -1 +1,2 @@
/target
/.scratch
+179
View File
@@ -2,6 +2,185 @@
One section per version, newest first.
## v0.10.4 (2026-11-07)
### Bug fixes
- The dock and taskbar show the remus icon for its window. The window now carries the app id me.anshorei.Fettleshed.Remus, which links it to the installed desktop file.
## v0.10.3 (2026-11-07)
### Features
- Settings has a Controls page listing every button and key, grouped by where it works, drawn for the controller in use or the keyboard.
- The controls bar shows only the controls that depend on the selection or the screen. Back, Play / Pause, Sections, Now playing, Search, Skip, Seek, Volume and Mute, and Select where it only opens something, are on the Controls page instead. The login screen is unchanged.
## v0.10.2 (2026-11-06)
### Bug fixes
- Leaving the last logged-in server while music plays, by logging out, forgetting it or a turned-down saved login, lets the screensaver run again on the login screen. Logging in after that starts with no leftover pause, position or restore state from the old queue.
## v0.10.1 (2026-11-06)
### Features
- Exit on the login screen is an X in the top right corner of the card instead of a button under Connect, which makes the card shorter. Up from the address field reaches it on a controller. When adding a server it cancels, as the button did.
## v0.10.0 (2026-11-06)
### Features
- A saved server in Settings can be logged out of or forgotten. The queue button opens a prompt naming the server, with Cancel selected. Log out drops the token or password and keeps the address and username. Forget removes the server, its saved queue and its cached covers. Both replace the double-press Remove.
- The login screen lists the saved servers beside the form. Picking one fills in its address and username and moves to the password. Selecting a logged-out server in Settings opens the same prefilled form, and logging in again reuses its entry.
- A saved login that the server turns down at startup is logged out, and the login screen opens prefilled with it instead of showing load errors.
### Bug fixes
- An http and an https login to the same host and user are labelled apart: the scheme is shown for http.
## v0.9.1 (2026-11-06)
### Features
- The dev script (REMUS_DEV_SCRIPT) has a fullscreen step that toggles fullscreen and a key:f11 step that presses F11. With RUST_LOG=remus=debug, each toggle logs whether the window was fullscreen and its size.
## v0.9.0 (2026-11-05)
### Features
- The queue can be shuffled from the now-playing screen. The queue button, or S on the keyboard, cycles through shuffling by track, shuffling by album and off. Album shuffle finishes the playing album first. Off goes back to the order the tracks were queued in and carries on after the playing track. Tracks queued while shuffled go to random places among those still to play. The mode shows beside the queue and comes back after a restart.
- Holding the activate button on an album, artist or playlist, or pressing Shift+S, plays it shuffled. On a track it shuffles the page the track is on. The activate button now acts when it is released.
- Shuffle all, the first tile in Random, plays random tracks from the whole library and keeps fetching more. Tracks queued meanwhile play next, ahead of the random ones.
## v0.8.7 (2026-11-04)
### Features
- On an album page, a track whose cover is a different picture from the album's shows its cover instead of its track number. Only servers that give tracks their own art, such as Navidrome, can show this; Nextcloud Music gives every track the album's cover.
## v0.8.6 (2026-11-04)
### Bug fixes
- Covers cached by versions before 0.8.0 are deleted on start. They were no longer used but stayed on disk.
## v0.8.5 (2026-11-04)
### Bug fixes
- The README says where the version is shown while the controls bar is hidden: in Settings, as a Version row.
## v0.8.4 (2026-11-04)
### Bug fixes
- While another app or a game is in front, the controller no longer also controls remus. Music keeps playing in the background, and media keys still work.
## v0.8.3 (2026-11-04)
### Bug fixes
- The now-playing cover, its background and the album art colours use the picture embedded in the playing track's file when it has one. Nextcloud Music gives every song of an album the album's cover, so tracks with their own art all showed the same one. Lists and the queue still show the server's cover.
## v0.8.2 (2026-11-04)
### Bug fixes
- On the now-playing screen the play/pause icon and the volume bar sit exactly under the middle of the progress bar. Before, the icon moved with the widths of the two times and the volume bar sat left of centre.
## v0.8.1 (2026-11-04)
### Features
- The password field on the login screen has an eye to show what was typed, and the queue button does the same from a controller while the field is selected. It is hidden again whenever the login screen opens.
## v0.8.0 (2026-11-04)
### Features
- Remus keeps several logins and switches between them from Settings, where the servers are listed first. Add server opens the login form, and Cancel goes back. Each server keeps its own queue: switching away stops it, and switching back brings it back paused where it was. A server is removed by pressing the queue button twice on its row.
- The shoulder triggers wrap around the sidebar, so Settings is one press back from Recently added.
- An existing login is kept as the first of the list, with nothing to re-enter.
## v0.7.0 (2026-11-04)
### Features
- Remus is an MPRIS player, so media keys, headphone buttons and the desktop's media controls can play, pause and skip, and the desktop shows the track that is playing. Headphone buttons work wherever the system passes them to MPRIS, as KDE does in Desktop Mode.
## v0.6.8 (2026-11-04)
### Features
- Settings has a Show controls bar toggle. Turned off, the bar with the button hints and the version is hidden on the browse and now-playing screens, and Settings lists the version instead. The login screen always shows it.
## v0.6.7 (2026-11-04)
### Bug fixes
- The volume level sits centred under the progress bar on the now-playing screen, and at the right of the bar at the bottom of the other screens, next to the time.
## v0.6.6 (2026-11-04)
### Features
- Volume control for remus's own playback, leaving the system volume alone. Right stick up and down changes it and clicking the right stick mutes; on a keyboard, + and - change it and m mutes. A level shows briefly after each change, the now-playing screen shows it under the times, and it is kept across restarts.
## v0.6.5 (2026-11-04)
### Features
- The now-playing screen shows a play or pause icon under the progress bar instead of the words Playing and Paused. The mini player uses the same icons, which no longer depend on the font.
## v0.6.4 (2026-11-04)
### Features
- Settings has a Cover backdrop slider for how much of the cover shows behind the now-playing screen, from off to 100 in steps of 10. Left and right change it. The default looks as before, and the strongest setting still keeps the text readable over a bright cover.
## v0.6.3 (2026-11-04)
### Features
- On the now-playing screen the cover flips around when the next track has a different picture, and settles with a small bounce. Tracks that share a picture do not flip, even on servers such as Navidrome that give every track its own cover id.
## v0.6.2 (2026-11-04)
### Bug fixes
- The app icon has thinner margins and a larger mark, so it stays legible at small sizes such as a taskbar or a repository avatar.
## v0.6.1 (2026-11-04)
### Bug fixes
- The logo is centred on the login screen.
## v0.6.0 (2026-11-04)
### Features
- The login screen has an Exit button below Connect, so remus can be closed from a controller before logging in.
## v0.5.0 (2026-11-04)
### Features
- While music plays, remus asks the system to keep the screensaver and sleep away, and lets go when playback is paused or stopped, or remus quits.
## v0.4.0 (2026-11-04)
### Features
- The queue survives a restart, a crash or SteamOS closing the app. It comes back paused on the same track, at most 15 seconds before where it was, and the server hears nothing until play is pressed. Each server keeps its own saved queue.
- Each release on Gitea has the Flatpak bundle attached, so installing on a Steam machine no longer needs a local build.
### Bug fixes
- A track that cannot be played is skipped on its own. Before, it could skip the next track too, or stop the queue.
- Play pressed while a track is still loading is no longer ignored.
## v0.3.0 (2026-11-04)
### Features
Generated
+7 -1
View File
@@ -4385,11 +4385,12 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]]
name = "remus"
version = "0.3.0"
version = "0.10.4"
dependencies = [
"anyhow",
"directories",
"env_logger",
"fastrand",
"fontique",
"gilrs",
"gstreamer",
@@ -4404,6 +4405,7 @@ dependencies = [
"slint-build",
"tokio",
"toml",
"zbus",
]
[[package]]
@@ -4906,6 +4908,7 @@ dependencies = [
"const-field-offset",
"i-slint-backend-linuxkms",
"i-slint-backend-selector",
"i-slint-backend-winit",
"i-slint-common",
"i-slint-core",
"i-slint-core-macros",
@@ -5407,8 +5410,10 @@ dependencies = [
"libc",
"mio",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"tracing",
"windows-sys 0.61.2",
]
@@ -6727,6 +6732,7 @@ dependencies = [
"rustix 1.1.6",
"serde",
"serde_repr",
"tokio",
"tracing",
"uds_windows",
"uuid",
+4 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "remus"
version = "0.3.0"
version = "0.10.4"
edition = "2024"
license = "MIT"
@@ -8,6 +8,7 @@ license = "MIT"
anyhow = "1.0.104"
directories = "6.0.0"
env_logger = "0.11.11"
fastrand = "2.5.0"
fontique = { version = "0.11", default-features = false, features = ["fontconfig-dlopen"] }
gilrs = "0.11.2"
gstreamer = "0.25.4"
@@ -18,9 +19,10 @@ md5 = "0.8.1"
reqwest = { version = "0.13.5", default-features = false, features = ["json", "rustls"] }
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
slint = "1.18.1"
slint = { version = "1.18.1", features = ["unstable-winit-030"] }
tokio = { version = "1.54.1", features = ["rt-multi-thread", "sync", "macros", "time"] }
toml = "1.1.8"
zbus = { version = "5.19.0", default-features = false, features = ["tokio"] }
[build-dependencies]
slint-build = "1.18.1"
+15 -2
View File
@@ -60,13 +60,13 @@ test-live: ## Every Subsonic call against a real server (DEMO_URL, DEMO_USER, DE
.PHONY: shots
shots: ## Screenshot the main screens against the demo server into target/shots
@mkdir -p $(SHOTS_DIR) $(SCRATCH)/config/remus $(SCRATCH)/cache
@mkdir -p $(SHOTS_DIR) $(SCRATCH)/config/remus $(SCRATCH)/cache $(SCRATCH)/state
@salt=$$(head -c 8 /dev/urandom | od -An -tx1 | tr -d ' \n'); \
token=$$(printf '%s%s' '$(DEMO_PASS)' "$$salt" | md5sum | cut -d' ' -f1); \
printf 'url = "%s"\nusername = "%s"\nsalt = "%s"\ntoken = "%s"\n' \
'$(DEMO_URL)' '$(DEMO_USER)' "$$salt" "$$token" > $(SCRATCH)/config/remus/config.toml
cargo build
XDG_CONFIG_HOME=$(CURDIR)/$(SCRATCH)/config XDG_CACHE_HOME=$(CURDIR)/$(SCRATCH)/cache \
XDG_CONFIG_HOME=$(CURDIR)/$(SCRATCH)/config XDG_CACHE_HOME=$(CURDIR)/$(SCRATCH)/cache XDG_STATE_HOME=$(CURDIR)/$(SCRATCH)/state \
REMUS_DEV_SCRIPT="wait:4000,shot:$(SHOTS_DIR)/home.png,right,activate,wait:3000,shot:$(SHOTS_DIR)/album.png,down,activate,wait:3000,now-playing,wait:2500,shot:$(SHOTS_DIR)/now-playing.png,play-pause,back,section-next,section-next,section-next,wait:3000,shot:$(SHOTS_DIR)/artists.png,quit" \
./target/debug/remus
@@ -187,6 +187,19 @@ bump:
git tag -a "v$$new" -m "v$$new"; \
echo "$$current -> $$new, tagged v$$new on $$(git rev-parse --short HEAD) ($$(git log -1 --format=%s))"
# Publishing. Builds the bundle for the version tagged on HEAD and attaches it
# to a new Gitea release, with the changelog entry as its notes.
GITEA_URL ?= https://gitea.anshorei.me
GITEA_REPO ?= Fettleshed/Remus
GITEA_REMOTE ?= origin
GITEA_TOKEN_FILE ?= $(HOME)/.config/gitea/token
.PHONY: publish
publish: ## Release the tagged version on Gitea with the Flatpak bundle attached
@VERSION="$(CURRENT)" GITEA_URL="$(GITEA_URL)" GITEA_REPO="$(GITEA_REPO)" \
GITEA_REMOTE="$(GITEA_REMOTE)" GITEA_TOKEN_FILE="$(GITEA_TOKEN_FILE)" \
bash scripts/publish.sh
.PHONY: clean
clean: ## Remove build output, screenshots and scratch config
cargo clean
+22 -5
View File
@@ -17,7 +17,7 @@ cargo run --release # fullscreen
cargo run --release -- --windowed
```
On first start remus asks for the server address, username and password. It stores the address, the username and an auth token (md5 of password + salt) in `~/.config/remus/config.toml`, mode 0600. The token is enough to log in to that server, so treat the file as a credential. Delete it to log in again.
On first start remus asks for the server address, username and password. It stores the address, the username and an auth token (md5 of password + salt) in `~/.config/remus/config.toml`, mode 0600. The token is enough to log in to that server, so treat the file as a credential. To log in again, or to remove a server, select it under Settings and press the queue button (Y on a controller, Q on a keyboard). Log out drops the token and keeps the address and username, so the login screen lists the server and only asks for the password. Forget removes the server along with its saved queue and cached covers. If the server stops accepting the saved token, remus logs it out at startup and asks for the password.
Some servers refuse token logins (Subsonic error 41), Nextcloud Music among them. For those remus logs in with the password itself and stores that in `config.toml` instead of a token, still mode 0600. Nextcloud Music wants the API password generated in its Music settings, not the Nextcloud login password.
@@ -27,7 +27,7 @@ Preferences live apart from the login, in `~/.config/remus/settings.toml`, so lo
## Install on SteamOS
Build the bundle on any Linux machine with Flatpak:
A published version has `remus-<version>.flatpak` attached to its release on Gitea (see [Versions](#versions)). Download that, or build the bundle on any Linux machine with Flatpak:
```
make flatpak-bundle # writes target/flatpak/remus.flatpak
@@ -37,13 +37,13 @@ make flatpak-bundle # writes target/flatpak/remus.flatpak
On the Steam machine, in Desktop Mode:
1. Copy `remus.flatpak` over and install it from a terminal: `flatpak install --user remus.flatpak`. Flatpak pulls the freedesktop 26.08 runtime from Flathub.
1. Copy the bundle over and install it from a terminal: `flatpak install --user remus.flatpak`. Flatpak pulls the freedesktop 26.08 runtime from Flathub.
2. In Steam, choose Games → Add a Non-Steam Game to My Library and pick Remus.
3. Back in Game Mode, open its controller settings and pick a Gamepad layout, so Steam passes the buttons through as a controller and not as keyboard and mouse.
The Flatpak keeps its login and cover cache in `~/.var/app/me.anshorei.Fettleshed.Remus/`, not in `~/.config` and `~/.cache`. Flatpak sets `XDG_CONFIG_HOME` itself there, so overriding it with `flatpak run --env` has no effect.
To update, build a new bundle and install it the same way.
A bundle does not update itself. To update, install the next version's bundle the same way.
## Controls
@@ -62,6 +62,8 @@ To update, build a new bundle and install it the same way.
| | F11 | Toggle fullscreen |
| | Ctrl+Q | Quit |
Settings has a Controls page with the same list, drawn with the buttons of the controller in use or the keyboard keys. The controls bar at the bottom shows only what depends on the selection, such as Add to queue on an album or Log out on a server. What works the same everywhere is left to the Controls page. The login screen shows all of its controls, since Settings cannot be reached from there.
With Steam running, remus listens only to Steam's virtual controller, so a pad Steam also exposes does not send every press twice. On a Deck, Steam + X opens the on-screen keyboard for the login and search fields.
## Development
@@ -86,9 +88,24 @@ A scripted run starts fullscreen like a normal one, so it also checks that start
### Versions
Every finished ticket bumps the version, so a build on the Deck can be matched to what it contains. The running version is shown at the bottom left of every screen.
Every finished ticket bumps the version, so a build on the Deck can be matched to what it contains. The running version is shown at the bottom left of the controls bar. With Show controls bar turned off in Settings, it is listed as a Version row in Settings instead. The login screen always shows the bar.
- `make patch` for a bug fix, `make minor` for a feature, `make major` only when a breaking change has been decided.
- Before bumping, add a `## v<new> (<date>)` entry at the top of `CHANGELOG.md`, with `### Features` and `### Bug fixes` subsections (leave out an empty one), and commit it with the change. `make version` prints the current version.
- Bump on local `master` only: fast-forward `master` to the finished work, switch to it, then bump. The targets refuse any other branch.
- The bump writes the new version to `Cargo.toml`, `Cargo.lock` and the Flatpak metainfo, amends that into the last commit and tags it `v<new>`. It refuses a dirty tree, a commit that is already tagged or pushed, and a version the changelog has no entry for.
To release a version once it is bumped:
1. `git push --follow-tags origin master`
2. `make publish`
`make publish` builds the Flatpak bundle for the version tagged on HEAD and creates its Gitea release. The release has the tag as its title and the changelog entry as its notes, and `remus-<version>.flatpak` is attached. It needs a Gitea token with `write:repository`, from `GITEA_TOKEN` or the file `~/.config/gitea/token` (`GITEA_TOKEN_FILE` to put it elsewhere). It checks everything before the build and refuses when:
- the tree is dirty
- HEAD is not tagged with the version in `Cargo.toml`
- there is no token
- the tag is not on the remote, or the remote's tag is a different one
- the version already has a release
If the upload fails, it deletes the release again so the next run starts clean. `GITEA_URL`, `GITEA_REPO` and `GITEA_REMOTE` default to this repository on `gitea.anshorei.me`.
+5 -3
View File
@@ -166,12 +166,14 @@ def variants() -> dict[str, str]:
# Full-bleed square, the composition of the source artwork.
v["remus-square.svg"] = svg(1024, 1024, mark(CREAM, 512, 512, 512), MAROON)
# Desktop / Flatpak app icon: rounded tile with a margin, 128 grid.
# Desktop / Flatpak app icon: rounded tile on a 128 grid. The margins are
# kept thin so the mark stays legible at 16 to 32 px. The mark sits 1 unit
# above centre because its wide base reads heavier than the R.
v["remus-icon.svg"] = svg(
128,
128,
f'<rect x="8" y="8" width="112" height="112" rx="26" fill="{MAROON}"/>'
+ mark(CREAM, 64, 64, 74),
f'<rect x="2" y="2" width="124" height="124" rx="24" fill="{MAROON}"/>'
+ mark(CREAM, 64, 63, 100),
)
# Lockups with the wordmark, transparent background.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><rect x="8" y="8" width="112" height="112" rx="26" fill="#5a0712"/><g fill="#faebda" transform="translate(64 64) scale(0.117741) translate(-627.5 -627.25)"><path d="M456.32,605.50C452.96,605.35 452.88,605.29 452.88,603.08C452.88,601.03 453.05,600.88 456.88,599.52C460.01,598.41 460.90,598.05 463.45,596.85C464.45,596.38 465.33,596.00 465.40,596.00C465.81,596.00 472.53,592.55 474.76,591.20C490.25,581.80 496.47,573.90 499.54,559.75L500.11,557.12L500.24,497.38C500.43,412.59 500.22,363.56 499.67,360.75C498.12,352.93 496.40,348.79 492.61,343.77C485.58,334.43 474.65,326.59 459.62,320.12C457.15,319.06 454.76,318.08 454.31,317.95C453.12,317.62 452.67,316.78 452.80,315.14C452.86,314.39 453.06,313.60 453.24,313.39C453.53,313.04 462.72,313.00 547.89,313.00C653.06,313.00 647.36,312.92 660.75,314.64C672.81,316.19 690.05,321.27 698.25,325.70C709.70,331.88 714.98,335.69 721.89,342.78C731.72,352.87 738.85,366.60 740.96,379.50C742.04,386.15 742.34,389.75 742.17,394.18C741.67,407.42 738.27,418.76 731.68,429.15C724.99,439.71 714.77,449.22 702.54,456.28C701.26,457.02 699.91,457.80 699.54,458.02C693.02,461.86 679.82,467.01 670.12,469.50C665.05,470.81 664.39,471.06 664.30,471.71C664.21,472.26 665.78,474.37 671.26,481.12C672.72,482.91 677.78,489.21 682.52,495.13C687.27,501.04 692.08,507.00 693.22,508.38C694.36,509.75 696.22,512.11 697.37,513.62C698.51,515.14 700.73,517.97 702.29,519.91C710.78,530.50 718.71,540.31 721.45,543.62C723.15,545.69 726.41,549.68 728.71,552.50C735.86,561.29 738.22,564.01 742.11,567.89C750.99,576.78 762.35,584.44 773.88,589.31C774.70,589.66 776.22,590.31 777.25,590.75C778.28,591.20 779.69,591.76 780.38,592.00C783.56,593.10 786.30,593.97 788.25,594.49C789.42,594.79 791.11,595.26 792.00,595.52C793.57,595.97 795.02,596.30 799.48,597.23C802.20,597.80 802.25,597.88 802.25,601.41C802.25,604.02 802.21,604.27 801.65,604.92L801.04,605.62L753.96,605.62C715.51,605.62 706.46,605.56 704.62,605.28C692.89,603.51 683.14,597.15 674.69,585.75C673.21,583.76 671.10,580.94 670.00,579.50C667.28,575.93 664.03,571.58 660.00,566.13C658.14,563.62 655.56,560.13 654.25,558.38C652.94,556.62 650.03,552.70 647.77,549.66C641.97,541.85 633.78,530.97 619.02,511.50C617.41,509.37 613.97,504.81 611.37,501.38C608.78,497.94 605.19,493.21 603.39,490.88C601.59,488.54 599.31,485.56 598.33,484.25C596.30,481.54 595.64,480.88 594.74,480.66C594.38,480.58 589.15,480.50 583.11,480.49L572.13,480.47L571.68,481.02C571.25,481.55 571.24,483.35 571.31,519.85C571.38,549.72 571.47,558.48 571.72,559.75C574.89,575.81 583.99,585.82 604.45,595.75C605.86,596.44 607.11,597.00 607.23,597.00C607.35,597.00 608.15,597.35 609.02,597.78C609.88,598.21 611.16,598.76 611.86,599.01C614.40,599.93 615.15,600.22 616.31,600.72L617.50,601.23L617.50,602.84C617.50,604.03 617.38,604.59 617.03,605.02L616.57,605.60L537.85,605.61C494.55,605.62 457.86,605.57 456.32,605.50ZM600.38,463.00C606.75,462.53 613.03,461.37 618.38,459.66C629.72,456.04 637.60,451.38 645.27,443.75C651.89,437.18 657.19,428.71 659.74,420.62C660.05,419.66 660.44,418.48 660.62,418.00C662.11,413.97 663.57,406.53 664.03,400.62C664.33,396.86 664.17,385.71 663.79,383.88C663.64,383.19 663.40,381.84 663.25,380.88C662.92,378.72 661.84,373.77 661.37,372.25C661.18,371.63 660.75,370.23 660.41,369.12C660.07,368.02 659.61,366.79 659.40,366.38C659.18,365.96 659.00,365.51 659.00,365.36C659.00,365.22 658.26,363.65 657.35,361.86C648.63,344.78 632.27,333.74 611.62,331.03C610.52,330.88 608.67,330.63 607.50,330.47C606.12,330.28 599.60,330.14 589.00,330.06L572.62,329.95L571.94,330.50L571.25,331.04L571.31,396.95L571.38,462.86L571.89,463.12C572.56,463.45 595.54,463.36 600.38,463.00Z"/><path fill-rule="evenodd" d="M453,633Q453,632 454,632H801Q802,632 802,633V653A13 12 0 0 1 789,665H466A13 12 0 0 1 453,653ZM493.5,677H761.5V683A16 16 0 0 1 745.5,699H509.5A16 16 0 0 1 493.5,683ZM520,710H735Q726,714 726,724V856Q726.5,870 735,873H520Q528.5,870 529,856V724Q529,714 520,710ZM562.5,855.5V738.5A11.5 11.5 0 0 1 585.5,738.5V855.5ZM616.0,855.5V738.5A11.5 11.5 0 0 1 639.0,738.5V855.5ZM669.5,855.5V738.5A11.5 11.5 0 0 1 692.5,738.5V855.5ZM487,905V900A16 16 0 0 1 503,884H752A16 16 0 0 1 768,900V905ZM460,941.5V930A14 14 0 0 1 474,916H781A14 14 0 0 1 795,930V941.5Z"/><rect x="460.0" y="741" width="30" height="115" rx="6"/><rect x="765.0" y="741" width="30" height="115" rx="6"/><rect x="400.0" y="707" width="30" height="182" rx="6"/><rect x="825.0" y="707" width="30" height="182" rx="6"/><rect x="340.0" y="757" width="30" height="99" rx="6"/><rect x="885.0" y="757" width="30" height="99" rx="6"/></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><rect x="2" y="2" width="124" height="124" rx="24" fill="#5a0712"/><g fill="#faebda" transform="translate(64 63) scale(0.159109) translate(-627.5 -627.25)"><path d="M456.32,605.50C452.96,605.35 452.88,605.29 452.88,603.08C452.88,601.03 453.05,600.88 456.88,599.52C460.01,598.41 460.90,598.05 463.45,596.85C464.45,596.38 465.33,596.00 465.40,596.00C465.81,596.00 472.53,592.55 474.76,591.20C490.25,581.80 496.47,573.90 499.54,559.75L500.11,557.12L500.24,497.38C500.43,412.59 500.22,363.56 499.67,360.75C498.12,352.93 496.40,348.79 492.61,343.77C485.58,334.43 474.65,326.59 459.62,320.12C457.15,319.06 454.76,318.08 454.31,317.95C453.12,317.62 452.67,316.78 452.80,315.14C452.86,314.39 453.06,313.60 453.24,313.39C453.53,313.04 462.72,313.00 547.89,313.00C653.06,313.00 647.36,312.92 660.75,314.64C672.81,316.19 690.05,321.27 698.25,325.70C709.70,331.88 714.98,335.69 721.89,342.78C731.72,352.87 738.85,366.60 740.96,379.50C742.04,386.15 742.34,389.75 742.17,394.18C741.67,407.42 738.27,418.76 731.68,429.15C724.99,439.71 714.77,449.22 702.54,456.28C701.26,457.02 699.91,457.80 699.54,458.02C693.02,461.86 679.82,467.01 670.12,469.50C665.05,470.81 664.39,471.06 664.30,471.71C664.21,472.26 665.78,474.37 671.26,481.12C672.72,482.91 677.78,489.21 682.52,495.13C687.27,501.04 692.08,507.00 693.22,508.38C694.36,509.75 696.22,512.11 697.37,513.62C698.51,515.14 700.73,517.97 702.29,519.91C710.78,530.50 718.71,540.31 721.45,543.62C723.15,545.69 726.41,549.68 728.71,552.50C735.86,561.29 738.22,564.01 742.11,567.89C750.99,576.78 762.35,584.44 773.88,589.31C774.70,589.66 776.22,590.31 777.25,590.75C778.28,591.20 779.69,591.76 780.38,592.00C783.56,593.10 786.30,593.97 788.25,594.49C789.42,594.79 791.11,595.26 792.00,595.52C793.57,595.97 795.02,596.30 799.48,597.23C802.20,597.80 802.25,597.88 802.25,601.41C802.25,604.02 802.21,604.27 801.65,604.92L801.04,605.62L753.96,605.62C715.51,605.62 706.46,605.56 704.62,605.28C692.89,603.51 683.14,597.15 674.69,585.75C673.21,583.76 671.10,580.94 670.00,579.50C667.28,575.93 664.03,571.58 660.00,566.13C658.14,563.62 655.56,560.13 654.25,558.38C652.94,556.62 650.03,552.70 647.77,549.66C641.97,541.85 633.78,530.97 619.02,511.50C617.41,509.37 613.97,504.81 611.37,501.38C608.78,497.94 605.19,493.21 603.39,490.88C601.59,488.54 599.31,485.56 598.33,484.25C596.30,481.54 595.64,480.88 594.74,480.66C594.38,480.58 589.15,480.50 583.11,480.49L572.13,480.47L571.68,481.02C571.25,481.55 571.24,483.35 571.31,519.85C571.38,549.72 571.47,558.48 571.72,559.75C574.89,575.81 583.99,585.82 604.45,595.75C605.86,596.44 607.11,597.00 607.23,597.00C607.35,597.00 608.15,597.35 609.02,597.78C609.88,598.21 611.16,598.76 611.86,599.01C614.40,599.93 615.15,600.22 616.31,600.72L617.50,601.23L617.50,602.84C617.50,604.03 617.38,604.59 617.03,605.02L616.57,605.60L537.85,605.61C494.55,605.62 457.86,605.57 456.32,605.50ZM600.38,463.00C606.75,462.53 613.03,461.37 618.38,459.66C629.72,456.04 637.60,451.38 645.27,443.75C651.89,437.18 657.19,428.71 659.74,420.62C660.05,419.66 660.44,418.48 660.62,418.00C662.11,413.97 663.57,406.53 664.03,400.62C664.33,396.86 664.17,385.71 663.79,383.88C663.64,383.19 663.40,381.84 663.25,380.88C662.92,378.72 661.84,373.77 661.37,372.25C661.18,371.63 660.75,370.23 660.41,369.12C660.07,368.02 659.61,366.79 659.40,366.38C659.18,365.96 659.00,365.51 659.00,365.36C659.00,365.22 658.26,363.65 657.35,361.86C648.63,344.78 632.27,333.74 611.62,331.03C610.52,330.88 608.67,330.63 607.50,330.47C606.12,330.28 599.60,330.14 589.00,330.06L572.62,329.95L571.94,330.50L571.25,331.04L571.31,396.95L571.38,462.86L571.89,463.12C572.56,463.45 595.54,463.36 600.38,463.00Z"/><path fill-rule="evenodd" d="M453,633Q453,632 454,632H801Q802,632 802,633V653A13 12 0 0 1 789,665H466A13 12 0 0 1 453,653ZM493.5,677H761.5V683A16 16 0 0 1 745.5,699H509.5A16 16 0 0 1 493.5,683ZM520,710H735Q726,714 726,724V856Q726.5,870 735,873H520Q528.5,870 529,856V724Q529,714 520,710ZM562.5,855.5V738.5A11.5 11.5 0 0 1 585.5,738.5V855.5ZM616.0,855.5V738.5A11.5 11.5 0 0 1 639.0,738.5V855.5ZM669.5,855.5V738.5A11.5 11.5 0 0 1 692.5,738.5V855.5ZM487,905V900A16 16 0 0 1 503,884H752A16 16 0 0 1 768,900V905ZM460,941.5V930A14 14 0 0 1 474,916H781A14 14 0 0 1 795,930V941.5Z"/><rect x="460.0" y="741" width="30" height="115" rx="6"/><rect x="765.0" y="741" width="30" height="115" rx="6"/><rect x="400.0" y="707" width="30" height="182" rx="6"/><rect x="825.0" y="707" width="30" height="182" rx="6"/><rect x="340.0" y="757" width="30" height="99" rx="6"/><rect x="885.0" y="757" width="30" height="99" rx="6"/></g></svg>

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

@@ -8,3 +8,4 @@ Terminal=false
Categories=AudioVideo;Audio;Player;
Keywords=music;subsonic;navidrome;player;
StartupNotify=true
StartupWMClass=me.anshorei.Fettleshed.Remus
@@ -20,6 +20,33 @@
</supports>
<content_rating type="oars-1.1"/>
<releases>
<release version="0.10.4" date="2026-11-07"/>
<release version="0.10.3" date="2026-11-07"/>
<release version="0.10.2" date="2026-11-06"/>
<release version="0.10.1" date="2026-11-06"/>
<release version="0.10.0" date="2026-11-06"/>
<release version="0.9.1" date="2026-11-06"/>
<release version="0.9.0" date="2026-11-05"/>
<release version="0.8.7" date="2026-11-04"/>
<release version="0.8.6" date="2026-11-04"/>
<release version="0.8.5" date="2026-11-04"/>
<release version="0.8.4" date="2026-11-04"/>
<release version="0.8.3" date="2026-11-04"/>
<release version="0.8.2" date="2026-11-04"/>
<release version="0.8.1" date="2026-11-04"/>
<release version="0.8.0" date="2026-11-04"/>
<release version="0.7.0" date="2026-11-04"/>
<release version="0.6.8" date="2026-11-04"/>
<release version="0.6.7" date="2026-11-04"/>
<release version="0.6.6" date="2026-11-04"/>
<release version="0.6.5" date="2026-11-04"/>
<release version="0.6.4" date="2026-11-04"/>
<release version="0.6.3" date="2026-11-04"/>
<release version="0.6.2" date="2026-11-04"/>
<release version="0.6.1" date="2026-11-04"/>
<release version="0.6.0" date="2026-11-04"/>
<release version="0.5.0" date="2026-11-04"/>
<release version="0.4.0" date="2026-11-04"/>
<release version="0.3.0" date="2026-11-04"/>
<release version="0.2.1" date="2026-11-04"/>
<release version="0.2.0" date="2026-11-04"/>
+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><rect x="8" y="8" width="112" height="112" rx="26" fill="#5a0712"/><g fill="#faebda" transform="translate(64 64) scale(0.117741) translate(-627.5 -627.25)"><path d="M456.32,605.50C452.96,605.35 452.88,605.29 452.88,603.08C452.88,601.03 453.05,600.88 456.88,599.52C460.01,598.41 460.90,598.05 463.45,596.85C464.45,596.38 465.33,596.00 465.40,596.00C465.81,596.00 472.53,592.55 474.76,591.20C490.25,581.80 496.47,573.90 499.54,559.75L500.11,557.12L500.24,497.38C500.43,412.59 500.22,363.56 499.67,360.75C498.12,352.93 496.40,348.79 492.61,343.77C485.58,334.43 474.65,326.59 459.62,320.12C457.15,319.06 454.76,318.08 454.31,317.95C453.12,317.62 452.67,316.78 452.80,315.14C452.86,314.39 453.06,313.60 453.24,313.39C453.53,313.04 462.72,313.00 547.89,313.00C653.06,313.00 647.36,312.92 660.75,314.64C672.81,316.19 690.05,321.27 698.25,325.70C709.70,331.88 714.98,335.69 721.89,342.78C731.72,352.87 738.85,366.60 740.96,379.50C742.04,386.15 742.34,389.75 742.17,394.18C741.67,407.42 738.27,418.76 731.68,429.15C724.99,439.71 714.77,449.22 702.54,456.28C701.26,457.02 699.91,457.80 699.54,458.02C693.02,461.86 679.82,467.01 670.12,469.50C665.05,470.81 664.39,471.06 664.30,471.71C664.21,472.26 665.78,474.37 671.26,481.12C672.72,482.91 677.78,489.21 682.52,495.13C687.27,501.04 692.08,507.00 693.22,508.38C694.36,509.75 696.22,512.11 697.37,513.62C698.51,515.14 700.73,517.97 702.29,519.91C710.78,530.50 718.71,540.31 721.45,543.62C723.15,545.69 726.41,549.68 728.71,552.50C735.86,561.29 738.22,564.01 742.11,567.89C750.99,576.78 762.35,584.44 773.88,589.31C774.70,589.66 776.22,590.31 777.25,590.75C778.28,591.20 779.69,591.76 780.38,592.00C783.56,593.10 786.30,593.97 788.25,594.49C789.42,594.79 791.11,595.26 792.00,595.52C793.57,595.97 795.02,596.30 799.48,597.23C802.20,597.80 802.25,597.88 802.25,601.41C802.25,604.02 802.21,604.27 801.65,604.92L801.04,605.62L753.96,605.62C715.51,605.62 706.46,605.56 704.62,605.28C692.89,603.51 683.14,597.15 674.69,585.75C673.21,583.76 671.10,580.94 670.00,579.50C667.28,575.93 664.03,571.58 660.00,566.13C658.14,563.62 655.56,560.13 654.25,558.38C652.94,556.62 650.03,552.70 647.77,549.66C641.97,541.85 633.78,530.97 619.02,511.50C617.41,509.37 613.97,504.81 611.37,501.38C608.78,497.94 605.19,493.21 603.39,490.88C601.59,488.54 599.31,485.56 598.33,484.25C596.30,481.54 595.64,480.88 594.74,480.66C594.38,480.58 589.15,480.50 583.11,480.49L572.13,480.47L571.68,481.02C571.25,481.55 571.24,483.35 571.31,519.85C571.38,549.72 571.47,558.48 571.72,559.75C574.89,575.81 583.99,585.82 604.45,595.75C605.86,596.44 607.11,597.00 607.23,597.00C607.35,597.00 608.15,597.35 609.02,597.78C609.88,598.21 611.16,598.76 611.86,599.01C614.40,599.93 615.15,600.22 616.31,600.72L617.50,601.23L617.50,602.84C617.50,604.03 617.38,604.59 617.03,605.02L616.57,605.60L537.85,605.61C494.55,605.62 457.86,605.57 456.32,605.50ZM600.38,463.00C606.75,462.53 613.03,461.37 618.38,459.66C629.72,456.04 637.60,451.38 645.27,443.75C651.89,437.18 657.19,428.71 659.74,420.62C660.05,419.66 660.44,418.48 660.62,418.00C662.11,413.97 663.57,406.53 664.03,400.62C664.33,396.86 664.17,385.71 663.79,383.88C663.64,383.19 663.40,381.84 663.25,380.88C662.92,378.72 661.84,373.77 661.37,372.25C661.18,371.63 660.75,370.23 660.41,369.12C660.07,368.02 659.61,366.79 659.40,366.38C659.18,365.96 659.00,365.51 659.00,365.36C659.00,365.22 658.26,363.65 657.35,361.86C648.63,344.78 632.27,333.74 611.62,331.03C610.52,330.88 608.67,330.63 607.50,330.47C606.12,330.28 599.60,330.14 589.00,330.06L572.62,329.95L571.94,330.50L571.25,331.04L571.31,396.95L571.38,462.86L571.89,463.12C572.56,463.45 595.54,463.36 600.38,463.00Z"/><path fill-rule="evenodd" d="M453,633Q453,632 454,632H801Q802,632 802,633V653A13 12 0 0 1 789,665H466A13 12 0 0 1 453,653ZM493.5,677H761.5V683A16 16 0 0 1 745.5,699H509.5A16 16 0 0 1 493.5,683ZM520,710H735Q726,714 726,724V856Q726.5,870 735,873H520Q528.5,870 529,856V724Q529,714 520,710ZM562.5,855.5V738.5A11.5 11.5 0 0 1 585.5,738.5V855.5ZM616.0,855.5V738.5A11.5 11.5 0 0 1 639.0,738.5V855.5ZM669.5,855.5V738.5A11.5 11.5 0 0 1 692.5,738.5V855.5ZM487,905V900A16 16 0 0 1 503,884H752A16 16 0 0 1 768,900V905ZM460,941.5V930A14 14 0 0 1 474,916H781A14 14 0 0 1 795,930V941.5Z"/><rect x="460.0" y="741" width="30" height="115" rx="6"/><rect x="765.0" y="741" width="30" height="115" rx="6"/><rect x="400.0" y="707" width="30" height="182" rx="6"/><rect x="825.0" y="707" width="30" height="182" rx="6"/><rect x="340.0" y="757" width="30" height="99" rx="6"/><rect x="885.0" y="757" width="30" height="99" rx="6"/></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"><rect x="2" y="2" width="124" height="124" rx="24" fill="#5a0712"/><g fill="#faebda" transform="translate(64 63) scale(0.159109) translate(-627.5 -627.25)"><path d="M456.32,605.50C452.96,605.35 452.88,605.29 452.88,603.08C452.88,601.03 453.05,600.88 456.88,599.52C460.01,598.41 460.90,598.05 463.45,596.85C464.45,596.38 465.33,596.00 465.40,596.00C465.81,596.00 472.53,592.55 474.76,591.20C490.25,581.80 496.47,573.90 499.54,559.75L500.11,557.12L500.24,497.38C500.43,412.59 500.22,363.56 499.67,360.75C498.12,352.93 496.40,348.79 492.61,343.77C485.58,334.43 474.65,326.59 459.62,320.12C457.15,319.06 454.76,318.08 454.31,317.95C453.12,317.62 452.67,316.78 452.80,315.14C452.86,314.39 453.06,313.60 453.24,313.39C453.53,313.04 462.72,313.00 547.89,313.00C653.06,313.00 647.36,312.92 660.75,314.64C672.81,316.19 690.05,321.27 698.25,325.70C709.70,331.88 714.98,335.69 721.89,342.78C731.72,352.87 738.85,366.60 740.96,379.50C742.04,386.15 742.34,389.75 742.17,394.18C741.67,407.42 738.27,418.76 731.68,429.15C724.99,439.71 714.77,449.22 702.54,456.28C701.26,457.02 699.91,457.80 699.54,458.02C693.02,461.86 679.82,467.01 670.12,469.50C665.05,470.81 664.39,471.06 664.30,471.71C664.21,472.26 665.78,474.37 671.26,481.12C672.72,482.91 677.78,489.21 682.52,495.13C687.27,501.04 692.08,507.00 693.22,508.38C694.36,509.75 696.22,512.11 697.37,513.62C698.51,515.14 700.73,517.97 702.29,519.91C710.78,530.50 718.71,540.31 721.45,543.62C723.15,545.69 726.41,549.68 728.71,552.50C735.86,561.29 738.22,564.01 742.11,567.89C750.99,576.78 762.35,584.44 773.88,589.31C774.70,589.66 776.22,590.31 777.25,590.75C778.28,591.20 779.69,591.76 780.38,592.00C783.56,593.10 786.30,593.97 788.25,594.49C789.42,594.79 791.11,595.26 792.00,595.52C793.57,595.97 795.02,596.30 799.48,597.23C802.20,597.80 802.25,597.88 802.25,601.41C802.25,604.02 802.21,604.27 801.65,604.92L801.04,605.62L753.96,605.62C715.51,605.62 706.46,605.56 704.62,605.28C692.89,603.51 683.14,597.15 674.69,585.75C673.21,583.76 671.10,580.94 670.00,579.50C667.28,575.93 664.03,571.58 660.00,566.13C658.14,563.62 655.56,560.13 654.25,558.38C652.94,556.62 650.03,552.70 647.77,549.66C641.97,541.85 633.78,530.97 619.02,511.50C617.41,509.37 613.97,504.81 611.37,501.38C608.78,497.94 605.19,493.21 603.39,490.88C601.59,488.54 599.31,485.56 598.33,484.25C596.30,481.54 595.64,480.88 594.74,480.66C594.38,480.58 589.15,480.50 583.11,480.49L572.13,480.47L571.68,481.02C571.25,481.55 571.24,483.35 571.31,519.85C571.38,549.72 571.47,558.48 571.72,559.75C574.89,575.81 583.99,585.82 604.45,595.75C605.86,596.44 607.11,597.00 607.23,597.00C607.35,597.00 608.15,597.35 609.02,597.78C609.88,598.21 611.16,598.76 611.86,599.01C614.40,599.93 615.15,600.22 616.31,600.72L617.50,601.23L617.50,602.84C617.50,604.03 617.38,604.59 617.03,605.02L616.57,605.60L537.85,605.61C494.55,605.62 457.86,605.57 456.32,605.50ZM600.38,463.00C606.75,462.53 613.03,461.37 618.38,459.66C629.72,456.04 637.60,451.38 645.27,443.75C651.89,437.18 657.19,428.71 659.74,420.62C660.05,419.66 660.44,418.48 660.62,418.00C662.11,413.97 663.57,406.53 664.03,400.62C664.33,396.86 664.17,385.71 663.79,383.88C663.64,383.19 663.40,381.84 663.25,380.88C662.92,378.72 661.84,373.77 661.37,372.25C661.18,371.63 660.75,370.23 660.41,369.12C660.07,368.02 659.61,366.79 659.40,366.38C659.18,365.96 659.00,365.51 659.00,365.36C659.00,365.22 658.26,363.65 657.35,361.86C648.63,344.78 632.27,333.74 611.62,331.03C610.52,330.88 608.67,330.63 607.50,330.47C606.12,330.28 599.60,330.14 589.00,330.06L572.62,329.95L571.94,330.50L571.25,331.04L571.31,396.95L571.38,462.86L571.89,463.12C572.56,463.45 595.54,463.36 600.38,463.00Z"/><path fill-rule="evenodd" d="M453,633Q453,632 454,632H801Q802,632 802,633V653A13 12 0 0 1 789,665H466A13 12 0 0 1 453,653ZM493.5,677H761.5V683A16 16 0 0 1 745.5,699H509.5A16 16 0 0 1 493.5,683ZM520,710H735Q726,714 726,724V856Q726.5,870 735,873H520Q528.5,870 529,856V724Q529,714 520,710ZM562.5,855.5V738.5A11.5 11.5 0 0 1 585.5,738.5V855.5ZM616.0,855.5V738.5A11.5 11.5 0 0 1 639.0,738.5V855.5ZM669.5,855.5V738.5A11.5 11.5 0 0 1 692.5,738.5V855.5ZM487,905V900A16 16 0 0 1 503,884H752A16 16 0 0 1 768,900V905ZM460,941.5V930A14 14 0 0 1 474,916H781A14 14 0 0 1 795,930V941.5Z"/><rect x="460.0" y="741" width="30" height="115" rx="6"/><rect x="765.0" y="741" width="30" height="115" rx="6"/><rect x="400.0" y="707" width="30" height="182" rx="6"/><rect x="825.0" y="707" width="30" height="182" rx="6"/><rect x="340.0" y="757" width="30" height="99" rx="6"/><rect x="885.0" y="757" width="30" height="99" rx="6"/></g></svg>

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

+7
View File
@@ -15,6 +15,12 @@ finish-args:
# GPU rendering and gamepads (evdev). --device=input would be narrower but
# needs Flatpak 1.15.6, which not every SteamOS release ships.
- --device=all
# Keeps the screensaver off while music plays, the way Chromium and
# Electron apps do. The XDG portal route needs no permission.
- --talk-name=org.freedesktop.ScreenSaver
# MPRIS, through which the desktop's media keys and headphone buttons
# reach the player.
- --own-name=org.mpris.MediaPlayer2.remus
build-options:
append-path: /usr/lib/sdk/rust-stable/bin
@@ -42,6 +48,7 @@ modules:
- .git
- .worklane
- .flatpak-builder
- .scratch
- type: dir
path: ../target/flatpak/vendor
dest: vendor
+119
View File
@@ -0,0 +1,119 @@
#!/usr/bin/env bash
# Publishes the tagged version on HEAD as a Gitea release with the Flatpak
# bundle attached. Run by `make publish`, after a bump and a push with tags.
#
# Every check runs before the slow Flatpak build, so a refusal costs seconds.
#
# Environment, set by the Makefile:
# VERSION version in Cargo.toml
# GITEA_URL e.g. https://gitea.anshorei.me
# GITEA_REPO owner/name, e.g. Fettleshed/Remus
# GITEA_REMOTE git remote that holds the tags
# GITEA_TOKEN or GITEA_TOKEN_FILE API token with write:repository
set -euo pipefail
fail() {
echo "error: $*" >&2
exit 1
}
for tool in curl jq git awk; do
command -v "$tool" >/dev/null || fail "$tool is not installed"
done
[ -n "${VERSION:-}" ] || fail "no version found in the [package] table of Cargo.toml"
tag="v$VERSION"
api="${GITEA_URL%/}/api/v1/repos/$GITEA_REPO"
asset="remus-$VERSION.flatpak"
# The bundle is built from the working tree, so it has to be the tagged commit.
if [ -n "$(git status --porcelain)" ]; then
echo "error: working tree is dirty, and the bundle would not be what $tag names:" >&2
git status --short >&2
exit 1
fi
head_tags=$(git tag --points-at HEAD --list 'v*')
if ! grep -qxF "$tag" <<<"$head_tags"; then
if [ -n "$head_tags" ]; then
fail "HEAD is tagged $(paste -sd' ' <<<"$head_tags"), but Cargo.toml says $VERSION"
fi
fail "HEAD is not tagged $tag. Check out the tag, or bump first with make patch, minor or major."
fi
# The token goes to curl in a header file, so it is never on a command line
# or in the output.
if [ -n "${GITEA_TOKEN:-}" ]; then
token=$GITEA_TOKEN
elif [ -n "${GITEA_TOKEN_FILE:-}" ] && [ -r "$GITEA_TOKEN_FILE" ]; then
token=$(tr -d '[:space:]' <"$GITEA_TOKEN_FILE")
else
fail "no Gitea token. Set GITEA_TOKEN, or put one in ${GITEA_TOKEN_FILE:-a file named by GITEA_TOKEN_FILE}. It needs write:repository."
fi
[ -n "$token" ] || fail "the Gitea token is empty"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
(umask 077 && printf 'Authorization: token %s\n' "$token" >"$tmp/auth")
unset token GITEA_TOKEN
# Calls the API. Prints the body and returns the HTTP status in $status.
call() {
local method=$1 url=$2
shift 2
status=$(curl -sS -o "$tmp/body" -w '%{http_code}' -X "$method" -H @"$tmp/auth" "$@" "$url") ||
fail "could not reach $GITEA_URL"
}
# The local tag object has to be the one on the remote, or the release would
# point at a tag that names another commit, or at none.
remote_tag=$(git ls-remote --tags "$GITEA_REMOTE" "refs/tags/$tag" | cut -f1) ||
fail "could not list the tags on $GITEA_REMOTE"
[ -n "$remote_tag" ] || fail "$tag is not on $GITEA_REMOTE yet. Push it first: git push --follow-tags $GITEA_REMOTE"
[ "$remote_tag" = "$(git rev-parse "refs/tags/$tag")" ] ||
fail "$tag on $GITEA_REMOTE is not the local $tag. Find out which one is right before publishing."
notes=$(awk -v h="## $tag " '
index($0, h) == 1 { found = 1; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md | sed -e '/./,$!d')
[ -n "$notes" ] || fail "CHANGELOG.md has no text under '## $tag'"
call GET "$api"
case $status in
200) ;;
401 | 403) fail "Gitea refused the token ($status). It needs write:repository on $GITEA_REPO." ;;
404) fail "no repository $GITEA_REPO on $GITEA_URL, or the token cannot see it" ;;
*) fail "checking $GITEA_REPO returned HTTP $status: $(cat "$tmp/body")" ;;
esac
call GET "$api/releases/tags/$tag"
case $status in
404) ;;
200) fail "$tag is already published: $(jq -r .html_url "$tmp/body"). Delete that release on Gitea to publish it again." ;;
*) fail "checking for an existing release returned HTTP $status: $(cat "$tmp/body")" ;;
esac
echo "Building the Flatpak bundle for $tag"
"${MAKE:-make}" --no-print-directory flatpak-bundle
cp target/flatpak/remus.flatpak "target/flatpak/$asset"
body=$(jq -n --arg tag "$tag" --arg notes "$notes" \
'{tag_name: $tag, name: $tag, body: $notes, draft: false, prerelease: false}')
call POST "$api/releases" -H 'Content-Type: application/json' --data "$body"
[ "$status" = 201 ] || fail "creating the release returned HTTP $status: $(cat "$tmp/body")"
id=$(jq -r .id "$tmp/body")
url=$(jq -r .html_url "$tmp/body")
call POST "$api/releases/$id/assets?name=$asset" -F "attachment=@target/flatpak/$asset"
if [ "$status" != 201 ]; then
echo "error: uploading $asset returned HTTP $status: $(cat "$tmp/body")" >&2
# A release without its bundle would block the next try, so take it back.
call DELETE "$api/releases/$id"
if [ "$status" = 204 ]; then
echo "Removed the release again, so make publish can be rerun." >&2
else
echo "Could not remove the release ($status). Delete $url by hand before rerunning." >&2
fi
exit 1
fi
echo "Published $tag with $asset: $url"
+1925 -98
View File
File diff suppressed because it is too large Load Diff
+343 -13
View File
@@ -11,7 +11,8 @@ use crate::subsonic::{Auth, Client};
/// Server credentials, written 0600. Either a token, md5(password + salt),
/// which is not the password but is enough to log in to this server; or, for
/// a server that refuses tokens, the password itself.
/// a server that refuses tokens, the password itself. Neither means logged
/// out: the server and username are kept for logging in again.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Config {
pub url: String,
@@ -39,6 +40,17 @@ impl Config {
}
}
pub fn logged_in(&self) -> bool {
self.password.is_some() || !self.token.is_empty()
}
/// Drops the credentials, keeping the server and username.
pub fn log_out(&mut self) {
self.salt.clear();
self.token.clear();
self.password = None;
}
pub fn client(&self) -> Client {
let auth = match &self.password {
Some(p) => Auth::Password(p.clone()),
@@ -63,30 +75,178 @@ pub fn cache_dir() -> Option<PathBuf> {
dirs().map(|d| d.cache_dir().to_path_buf())
}
pub fn load() -> Result<Option<Config>> {
let Some(path) = config_path() else { return Ok(None) };
/// For state that is not configuration, such as the saved queue. Not every
/// platform has a state directory, so it falls back to the data directory.
pub fn state_dir() -> Option<PathBuf> {
dirs().map(|d| d.state_dir().unwrap_or(d.data_dir()).to_path_buf())
}
impl Config {
/// Names the server and user, as the sidebar shows them.
pub fn label(&self) -> String {
server_label(&self.url, &self.username)
}
fn same_login(&self, other: &Config) -> bool {
self.url == other.url && self.username == other.username
}
}
/// "user on host". The scheme is left out for https only, so an http and an
/// https login to the same host can be told apart.
pub fn server_label(url: &str, username: &str) -> String {
let host = match url.split_once("://") {
Some(("https", rest)) => rest,
_ => url,
};
format!("{} on {}", username, host.trim_end_matches('/'))
}
/// Every saved login, and which one is browsed.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Logins {
/// Index into `servers`. Points at a logged-in server whenever there is
/// one.
#[serde(default)]
pub active: usize,
/// `[[server]]` tables in the file.
#[serde(rename = "server", default)]
pub servers: Vec<Config>,
}
impl Logins {
/// The server being browsed, or none when every saved one is logged out.
pub fn active(&self) -> Option<&Config> {
self.servers.get(self.active).filter(|c| c.logged_in())
}
/// Moves `active` off a server that is gone or logged out, to the first
/// logged-in one.
fn settle_active(&mut self) {
if self.active().is_none() {
self.active = self.servers.iter().position(Config::logged_in).unwrap_or(0);
}
}
/// The saved entry for this server and user, logged in or not.
pub fn find(&self, url: &str, username: &str) -> Option<usize> {
self.servers.iter().position(|s| s.url == url && s.username == username)
}
/// Adds a login, or refreshes the saved one for the same server and user,
/// and makes it the active one.
pub fn add(&mut self, cfg: Config) {
match self.servers.iter().position(|s| s.same_login(&cfg)) {
Some(i) => {
self.servers[i] = cfg;
self.active = i;
}
None => {
self.servers.push(cfg);
self.active = self.servers.len() - 1;
}
}
}
/// Removes a login. The active one stays the same server where it can;
/// removing it makes the first remaining logged-in server active.
pub fn remove(&mut self, i: usize) {
if i >= self.servers.len() {
return;
}
self.servers.remove(i);
if i < self.active {
self.active -= 1;
} else if i == self.active {
self.active = 0;
}
self.settle_active();
}
/// Logs out of a server, keeping its entry. Logging out of the active one
/// makes the first logged-in server active.
pub fn log_out(&mut self, i: usize) {
if let Some(s) = self.servers.get_mut(i) {
s.log_out();
self.settle_active();
}
}
}
/// The single login of earlier versions, or the list. Tried in that order:
/// every field of the list has a default, so it would take an old file as an
/// empty list, while the old shape needs `url` and `username` at the top.
#[derive(Deserialize)]
#[serde(untagged)]
enum Stored {
One(Config),
List(Logins),
}
fn parse_logins(text: &str) -> Result<Logins> {
Ok(match toml::from_str::<Stored>(text)? {
Stored::List(mut l) => {
if l.active >= l.servers.len() {
l.active = 0;
}
l.settle_active();
l
}
Stored::One(c) => Logins {
active: 0,
servers: vec![c],
},
})
}
pub fn load() -> Result<Logins> {
let Some(path) = config_path() else {
return Ok(Logins::default());
};
match fs::read_to_string(&path) {
Ok(text) => Ok(Some(
toml::from_str(&text).with_context(|| format!("parsing {}", path.display()))?,
)),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None),
Ok(text) => parse_logins(&text).with_context(|| format!("parsing {}", path.display())),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(Logins::default()),
Err(e) => Err(e).with_context(|| format!("reading {}", path.display())),
}
}
pub fn save(cfg: &Config) -> Result<()> {
pub fn save(logins: &Logins) -> Result<()> {
let path = config_path().context("no config directory")?;
write_atomic(&path, &toml::to_string(cfg)?)?;
log::info!("saved login to {}", path.display());
write_atomic(&path, &toml::to_string(logins)?)?;
log::info!("saved {} login(s) to {}", logins.servers.len(), path.display());
Ok(())
}
/// Preferences. Kept apart from the login, so logging out does not reset them.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct Settings {
/// Tint the UI with the colours of the playing track's cover.
pub album_art_colours: bool,
/// How strongly the cover shows behind the now-playing screen, 0 to 100.
pub cover_backdrop: u8,
/// Playback volume, 0 to 100. Only remus's own stream, not the system's.
pub volume: u8,
/// Muted, keeping `volume` for when it is unmuted.
pub muted: bool,
/// The bar with the button hints and the version. The login screen shows
/// it regardless.
pub show_hint_bar: bool,
}
/// The cover backdrop strength that looks like it did before it was a setting.
pub const COVER_BACKDROP_DEFAULT: u8 = 30;
impl Default for Settings {
fn default() -> Self {
Settings {
album_art_colours: false,
cover_backdrop: COVER_BACKDROP_DEFAULT,
volume: 100,
muted: false,
show_hint_bar: true,
}
}
}
fn settings_path() -> Option<PathBuf> {
@@ -119,11 +279,13 @@ pub fn save_settings(s: &Settings) -> Result<()> {
/// Writes aside, syncs, then renames over the old file, so a power cut
/// mid-save leaves either the old file or the new one, never a torn one.
/// Owner-only, since the login file holds a token.
fn write_atomic(path: &Path, text: &str) -> Result<()> {
pub fn write_atomic(path: &Path, text: &str) -> Result<()> {
if let Some(dir) = path.parent() {
fs::create_dir_all(dir)?;
}
let tmp = path.with_extension("toml.tmp");
let mut tmp = path.as_os_str().to_owned();
tmp.push(".tmp");
let tmp = PathBuf::from(tmp);
let mut f = fs::OpenOptions::new()
.write(true)
.create(true)
@@ -180,17 +342,185 @@ mod tests {
assert!(!text.contains("salt") && !text.contains("token"), "{text}");
}
fn login(url: &str, user: &str, auth: Auth) -> Config {
Config::from_client(&Client::new(url, user, auth))
}
#[test]
fn a_single_login_file_loads_as_the_only_login() {
let old = "url = \"https://h\"\nusername = \"u\"\nsalt = \"s\"\ntoken = \"t\"\n";
let l = parse_logins(old).unwrap();
assert_eq!(l.servers.len(), 1);
assert_eq!(l.active, 0);
assert_eq!(l.active().unwrap().username, "u");
let old = "url = \"https://h\"\nusername = \"u\"\npassword = \"p\"\n";
let l = parse_logins(old).unwrap();
assert_eq!(*l.active().unwrap().client().auth(), Auth::Password("p".into()));
}
#[test]
fn the_login_list_round_trips_with_both_auth_methods() {
let mut l = Logins::default();
l.add(login(
"https://a",
"u",
Auth::Token {
salt: "s".into(),
token: "t".into(),
},
));
l.add(login("https://b", "v", Auth::Password("p".into())));
let text = toml::to_string(&l).unwrap();
assert!(text.contains("[[server]]"), "{text}");
let back = parse_logins(&text).unwrap();
assert_eq!(back, l);
assert_eq!(back.active, 1);
}
#[test]
fn adding_the_same_login_again_replaces_it() {
let mut l = Logins::default();
l.add(login("https://a", "u", Auth::Password("old".into())));
l.add(login("https://b", "u", Auth::Password("p".into())));
l.add(login("https://a", "u", Auth::Password("new".into())));
assert_eq!(l.servers.len(), 2);
assert_eq!(l.active, 0);
assert_eq!(*l.servers[0].client().auth(), Auth::Password("new".into()));
}
#[test]
fn removing_keeps_the_active_server_where_it_can() {
let mut l = Logins::default();
for host in ["https://a", "https://b", "https://c"] {
l.add(login(host, "u", Auth::Password("p".into())));
}
l.active = 2;
l.remove(0);
assert_eq!(l.active().unwrap().url, "https://c");
l.remove(1);
assert_eq!(l.active().unwrap().url, "https://b");
l.remove(0);
assert!(l.active().is_none());
}
#[test]
fn an_out_of_range_active_index_falls_back_to_the_first() {
let text = "active = 5\n[[server]]\nurl = \"https://a\"\nusername = \"u\"\npassword = \"p\"\n";
assert_eq!(parse_logins(text).unwrap().active, 0);
}
#[test]
fn a_logged_out_login_keeps_its_server_and_round_trips() {
let mut l = Logins::default();
l.add(login(
"https://a",
"u",
Auth::Token {
salt: "s".into(),
token: "t".into(),
},
));
l.add(login("https://b", "v", Auth::Password("p".into())));
l.log_out(0);
l.log_out(1);
let text = toml::to_string(&l).unwrap();
assert!(
!text.contains("salt") && !text.contains("token") && !text.contains("password"),
"{text}"
);
let back = parse_logins(&text).unwrap();
assert_eq!(back, l);
assert_eq!(back.servers.len(), 2);
assert!(back.servers.iter().all(|s| !s.logged_in()));
assert_eq!(back.servers[1].url, "https://b");
assert_eq!(back.servers[1].username, "v");
assert!(back.active().is_none());
}
#[test]
fn the_active_login_skips_logged_out_servers() {
let mut l = Logins::default();
for host in ["https://a", "https://b", "https://c"] {
l.add(login(host, "u", Auth::Password("p".into())));
}
l.active = 0;
l.log_out(1);
assert_eq!(l.active().unwrap().url, "https://a");
l.log_out(0);
assert_eq!(l.active().unwrap().url, "https://c");
l.log_out(2);
assert!(l.active().is_none());
// Logging in again reuses the entry and makes it active.
l.add(login("https://b", "u", Auth::Password("p".into())));
assert_eq!(l.servers.len(), 3);
assert_eq!(l.active().unwrap().url, "https://b");
}
#[test]
fn a_saved_active_index_on_a_logged_out_server_moves_to_a_logged_in_one() {
let text = "active = 0\n[[server]]\nurl = \"https://a\"\nusername = \"u\"\n\
[[server]]\nurl = \"https://b\"\nusername = \"u\"\npassword = \"p\"\n";
let l = parse_logins(text).unwrap();
assert_eq!(l.active, 1);
assert_eq!(l.active().unwrap().url, "https://b");
}
#[test]
fn removing_the_active_login_skips_logged_out_servers() {
let mut l = Logins::default();
for host in ["https://a", "https://b", "https://c"] {
l.add(login(host, "u", Auth::Password("p".into())));
}
l.log_out(0);
l.active = 1;
l.remove(1);
assert_eq!(l.active().unwrap().url, "https://c");
}
#[test]
fn a_login_list_from_v0_8_0_loads_logged_in() {
let text = "active = 1\n\
[[server]]\nurl = \"https://a\"\nusername = \"u\"\nsalt = \"s\"\ntoken = \"t\"\n\
[[server]]\nurl = \"https://b\"\nusername = \"v\"\npassword = \"p\"\n";
let l = parse_logins(text).unwrap();
assert_eq!(l.servers.len(), 2);
assert!(l.servers.iter().all(Config::logged_in));
assert_eq!(l.active().unwrap().url, "https://b");
}
#[test]
fn labels_tell_http_and_https_apart() {
assert_eq!(server_label("https://h/", "u"), "u on h");
assert_eq!(server_label("http://h", "u"), "u on http://h");
}
#[test]
fn settings_default_when_fields_are_missing() {
let s: Settings = toml::from_str("").unwrap();
assert_eq!(s, Settings::default());
assert!(!s.album_art_colours);
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
assert_eq!(s.volume, 100);
assert!(!s.muted);
assert!(s.show_hint_bar);
}
#[test]
fn settings_from_before_the_backdrop_load_its_default() {
let s: Settings = toml::from_str("album_art_colours = true\n").unwrap();
assert!(s.album_art_colours);
assert_eq!(s.cover_backdrop, COVER_BACKDROP_DEFAULT);
assert!(s.show_hint_bar);
}
#[test]
fn settings_round_trip() {
let s = Settings {
album_art_colours: true,
cover_backdrop: 70,
volume: 35,
muted: true,
show_hint_bar: false,
};
let back: Settings = toml::from_str(&toml::to_string(&s).unwrap()).unwrap();
assert_eq!(back, s);
+15
View File
@@ -56,6 +56,13 @@ fn step(ui: slint::Weak<AppWindow>, steps: Vec<String>, i: usize) {
Err(e) => log::error!("snapshot failed: {e}"),
}
}
Some(("key", "f11")) => {
use slint::platform::{Key, WindowEvent};
let text: slint::SharedString = Key::F11.into();
win.window()
.dispatch_event(WindowEvent::KeyPressed { text: text.clone() });
win.window().dispatch_event(WindowEvent::KeyReleased { text });
}
Some(("prompts", kind)) => {
use crate::prompts::Family;
let family = match kind {
@@ -88,9 +95,17 @@ fn step(ui: slint::Weak<AppWindow>, steps: Vec<String>, i: usize) {
"next" => Action::Next,
"play-pause" => Action::PlayPause,
"section-next" => Action::SectionNext,
"section-prev" => Action::SectionPrev,
"now-playing" => Action::NowPlaying,
"search" => Action::Search,
"quit" => Action::Quit,
"volume-up" => Action::VolumeUp,
"volume-down" => Action::VolumeDown,
"mute" => Action::ToggleMute,
"cycle-shuffle" => Action::CycleShuffle,
"shuffle" => Action::Shuffle,
"hold-activate" => Action::HoldActivate,
"fullscreen" => Action::ToggleFullscreen,
other => {
log::warn!("unknown dev script step {other}");
Action::None
+316
View File
@@ -0,0 +1,316 @@
//! Keeps the screensaver and idle sleep away while music plays.
//!
//! Two routes, each held independently: org.freedesktop.ScreenSaver, the one
//! Chromium and Electron apps use during playback, and the XDG portal's
//! Inhibit, which needs no Flatpak permission and covers desktops where the
//! first is not served. A route that fails is logged once and otherwise
//! ignored. Services normally drop an inhibit when its client leaves the bus,
//! so a crash should not leave one behind.
use std::collections::HashMap;
use std::time::Duration;
use anyhow::Result;
use tokio::runtime::Handle;
use tokio::sync::{oneshot, watch};
use zbus::Connection;
use zbus::zvariant::{OwnedObjectPath, Value};
const APP: &str = "remus";
const REASON: &str = "Playing music";
/// The portal's idle and suspend flags.
const PORTAL_FLAGS: u32 = 4 | 8;
pub struct Inhibitor {
want: watch::Sender<bool>,
done: oneshot::Receiver<()>,
rt: Handle,
}
impl Inhibitor {
pub fn spawn(rt: &Handle) -> Inhibitor {
let (want, rx) = watch::channel(false);
let (done_tx, done) = oneshot::channel();
rt.spawn(async move {
run(DBus::default(), rx).await;
let _ = done_tx.send(());
});
Inhibitor {
want,
done,
rt: rt.clone(),
}
}
/// Hold the inhibit while `on`, release it otherwise.
pub fn set(&self, on: bool) {
self.want.send_if_modified(|v| std::mem::replace(v, on) != on);
}
/// Releases what is held before the runtime goes away. Called from
/// outside the runtime, so it may block briefly.
pub fn shutdown(self) {
let Inhibitor { want, done, rt } = self;
drop(want);
// The timer needs the runtime, so it is made inside block_on.
let _ = rt.block_on(async { tokio::time::timeout(Duration::from_secs(1), done).await });
}
}
/// One way of inhibiting, so the loop can be tested without a bus.
trait Backend {
/// Takes every route that is not held yet.
async fn acquire(&mut self);
/// Gives back every route that is held.
async fn release(&mut self);
}
/// Follows the wanted state until the sender is dropped, then releases.
async fn run(mut backend: impl Backend, mut want: watch::Receiver<bool>) {
while want.changed().await.is_ok() {
// Changes that arrive while a call is in flight coalesce into the latest.
if *want.borrow_and_update() {
backend.acquire().await;
} else {
backend.release().await;
}
}
backend.release().await;
}
#[derive(Default)]
struct DBus {
conn: Option<Connection>,
cookie: Option<u32>,
request: Option<OwnedObjectPath>,
warned_bus: bool,
warned_screensaver: bool,
warned_portal: bool,
}
impl DBus {
async fn connection(&mut self) -> Option<Connection> {
if self.conn.is_none() {
match Connection::session().await {
Ok(c) => self.conn = Some(c),
Err(e) => {
warn_once(
&mut self.warned_bus,
format_args!("no session bus, the screensaver stays on: {e}"),
);
return None;
}
}
}
self.conn.clone()
}
}
impl Backend for DBus {
async fn acquire(&mut self) {
let Some(conn) = self.connection().await else { return };
if self.cookie.is_none() {
match screensaver_inhibit(&conn).await {
Ok(c) => {
log::debug!("screensaver inhibited (cookie {c})");
self.cookie = Some(c);
}
Err(e) => warn_once(
&mut self.warned_screensaver,
format_args!("org.freedesktop.ScreenSaver inhibit failed: {e:#}"),
),
}
}
if self.request.is_none() {
match portal_inhibit(&conn).await {
Ok(r) => {
log::debug!("portal inhibit requested ({})", r.as_str());
self.request = Some(r);
}
Err(e) => warn_once(&mut self.warned_portal, format_args!("portal inhibit failed: {e:#}")),
}
}
}
async fn release(&mut self) {
let Some(conn) = self.conn.clone() else { return };
if let Some(c) = self.cookie.take() {
let r = conn
.call_method(
Some("org.freedesktop.ScreenSaver"),
"/org/freedesktop/ScreenSaver",
Some("org.freedesktop.ScreenSaver"),
"UnInhibit",
&(c,),
)
.await;
match r {
Ok(_) => log::debug!("screensaver released (cookie {c})"),
Err(e) => log::warn!("org.freedesktop.ScreenSaver uninhibit failed: {e}"),
}
}
if let Some(r) = self.request.take()
&& let Err(e) = conn
.call_method(
Some("org.freedesktop.portal.Desktop"),
r.as_str(),
Some("org.freedesktop.portal.Request"),
"Close",
&(),
)
.await
{
if gone(&e) {
// Some portal backends drop the request at once, for example
// when they do not implement Inhibit, so there is nothing to close.
log::debug!("portal inhibit was not held any more: {e}");
} else {
log::warn!("portal inhibit release failed: {e}");
}
}
}
}
async fn screensaver_inhibit(conn: &Connection) -> Result<u32> {
let reply = conn
.call_method(
Some("org.freedesktop.ScreenSaver"),
"/org/freedesktop/ScreenSaver",
Some("org.freedesktop.ScreenSaver"),
"Inhibit",
&(APP, REASON),
)
.await?;
Ok(reply.body().deserialize::<u32>()?)
}
async fn portal_inhibit(conn: &Connection) -> Result<OwnedObjectPath> {
let options: HashMap<&str, Value<'_>> = HashMap::from([("reason", Value::from(REASON))]);
let reply = conn
.call_method(
Some("org.freedesktop.portal.Desktop"),
"/org/freedesktop/portal/desktop",
Some("org.freedesktop.portal.Inhibit"),
"Inhibit",
// No parent window identifier: the inhibit is for the whole app.
&("", PORTAL_FLAGS, options),
)
.await?;
Ok(reply.body().deserialize::<OwnedObjectPath>()?)
}
/// The object being called no longer exists.
fn gone(e: &zbus::Error) -> bool {
const GONE: [&str; 2] = [
"org.freedesktop.DBus.Error.UnknownMethod",
"org.freedesktop.DBus.Error.UnknownObject",
];
match e {
zbus::Error::MethodError(name, ..) => GONE.contains(&name.as_str()),
zbus::Error::FDO(f) => {
matches!(
**f,
zbus::fdo::Error::UnknownMethod(_) | zbus::fdo::Error::UnknownObject(_)
)
}
_ => false,
}
}
fn warn_once(warned: &mut bool, msg: std::fmt::Arguments<'_>) {
if std::mem::replace(warned, true) {
log::debug!("{msg}");
} else {
log::warn!("{msg}");
}
}
#[cfg(test)]
mod tests {
use std::sync::{Arc, Mutex};
use super::*;
#[derive(Clone, Default)]
struct Fake {
calls: Arc<Mutex<Vec<&'static str>>>,
held: Arc<Mutex<bool>>,
}
impl Backend for Fake {
async fn acquire(&mut self) {
self.calls.lock().unwrap().push("acquire");
*self.held.lock().unwrap() = true;
}
async fn release(&mut self) {
self.calls.lock().unwrap().push("release");
*self.held.lock().unwrap() = false;
}
}
/// Sends each state and lets the loop act on it before the next.
async fn drive(states: &[bool]) -> Fake {
let fake = Fake::default();
let (tx, rx) = watch::channel(false);
let task = tokio::spawn(run(fake.clone(), rx));
for &s in states {
tx.send_if_modified(|v| std::mem::replace(v, s) != s);
tokio::task::yield_now().await;
}
drop(tx);
task.await.unwrap();
fake
}
#[tokio::test]
async fn follows_play_and_pause() {
let fake = drive(&[true, false, true]).await;
assert_eq!(
*fake.calls.lock().unwrap(),
["acquire", "release", "acquire", "release"]
);
}
#[tokio::test]
async fn repeated_state_does_not_call_again() {
let fake = drive(&[true, true, true]).await;
assert_eq!(*fake.calls.lock().unwrap(), ["acquire", "release"]);
}
#[tokio::test]
async fn releases_when_dropped_while_held() {
let fake = drive(&[true]).await;
assert!(!*fake.held.lock().unwrap());
}
#[tokio::test]
async fn nothing_held_when_never_played() {
let fake = drive(&[false]).await;
assert_eq!(*fake.calls.lock().unwrap(), ["release"]);
assert!(!*fake.held.lock().unwrap());
}
/// Against the real session bus: `cargo test live_inhibit -- --ignored`.
/// Prints which routes this session serves rather than failing on a
/// missing one, since a desktop may serve only one of them.
#[tokio::test]
#[ignore]
async fn live_inhibit() {
let conn = Connection::session().await.expect("session bus");
let ss = screensaver_inhibit(&conn).await;
let portal = portal_inhibit(&conn).await;
println!("org.freedesktop.ScreenSaver: {ss:?}");
println!("portal: {portal:?}");
assert!(ss.is_ok() || portal.is_ok(), "neither route is served");
let mut bus = DBus {
conn: Some(conn),
cookie: ss.ok(),
request: portal.ok(),
..DBus::default()
};
bus.release().await;
assert!(bus.cookie.is_none() && bus.request.is_none());
}
}
+45 -5
View File
@@ -27,6 +27,8 @@ const REPEAT_DELAY: Duration = Duration::from_millis(380);
const REPEAT_SLOW: Duration = Duration::from_millis(110);
const REPEAT_FAST: Duration = Duration::from_millis(45);
const FAST_AFTER: Duration = Duration::from_millis(1500);
/// How long South is held before it counts as a long press.
const LONG_PRESS: Duration = Duration::from_millis(500);
const STICK_ON: f32 = 0.55;
const STICK_OFF: f32 = 0.35;
@@ -37,6 +39,14 @@ enum Source {
RightStick,
}
/// South acts on release, so a long press can mean something else.
struct SouthPress {
family: Family,
since: Instant,
/// Sent as a long press already, so the release sends nothing.
long: bool,
}
struct Held {
source: Source,
action: Action,
@@ -66,6 +76,7 @@ pub fn spawn_gamepad(emit: impl Fn(PadEvent) + Send + 'static) {
}
emit(PadEvent::Present(present(&gilrs, &mut families)));
let mut held: Option<Held> = None;
let mut south: Option<SouthPress> = None;
loop {
while let Some(ev) = gilrs.next_event_blocking(Some(Duration::from_millis(15))) {
if matches!(ev.event, EventType::Connected | EventType::Disconnected) {
@@ -77,6 +88,20 @@ pub fn spawn_gamepad(emit: impl Fn(PadEvent) + Send + 'static) {
}
let family = families.family(&gilrs, ev.id);
match ev.event {
EventType::ButtonPressed(Button::South, _) => {
south = Some(SouthPress {
family,
since: Instant::now(),
long: false,
});
}
EventType::ButtonReleased(Button::South, _) => {
if let Some(p) = south.take()
&& !p.long
{
emit(PadEvent::Action(Action::Activate, p.family));
}
}
EventType::ButtonPressed(b, _) => {
if let Some(a) = dpad_action(b) {
held = Some(start_hold(Source::DPad, a, family));
@@ -93,7 +118,7 @@ pub fn spawn_gamepad(emit: impl Fn(PadEvent) + Send + 'static) {
EventType::AxisChanged(axis, value, _) => {
let source = match axis {
Axis::LeftStickX | Axis::LeftStickY => Source::LeftStick,
Axis::RightStickX => Source::RightStick,
Axis::RightStickX | Axis::RightStickY => Source::RightStick,
_ => continue,
};
let pad = gilrs.gamepad(ev.id);
@@ -108,10 +133,20 @@ pub fn spawn_gamepad(emit: impl Fn(PadEvent) + Send + 'static) {
_ => {}
}
}
EventType::Disconnected => held = None,
EventType::Disconnected => {
held = None;
south = None;
}
_ => {}
}
}
if let Some(p) = south.as_mut()
&& !p.long
&& p.since.elapsed() >= LONG_PRESS
{
p.long = true;
emit(PadEvent::Action(Action::HoldActivate, p.family));
}
if let Some(h) = held.as_mut() {
let now = Instant::now();
if now >= h.next {
@@ -216,7 +251,6 @@ fn dpad_action(b: Button) -> Option<Action> {
fn button_action(b: Button) -> Option<Action> {
Some(match b {
Button::South => Action::Activate,
Button::East => Action::Back,
Button::West => Action::PlayPause,
Button::North => Action::Queue,
@@ -226,6 +260,7 @@ fn button_action(b: Button) -> Option<Action> {
Button::RightTrigger2 => Action::SectionNext,
Button::Start => Action::NowPlaying,
Button::Select => Action::Search,
Button::RightThumb => Action::ToggleMute,
_ => return None,
})
}
@@ -247,12 +282,17 @@ fn stick_direction(source: Source, pad: &gilrs::Gamepad<'_>, _changed: f32, held
Some(if y > 0.0 { Action::Up } else { Action::Down })
}
}
// Across seeks, up and down set the volume. The dominant axis wins, so
// a diagonal push does only one of them.
Source::RightStick => {
let x = pad.value(Axis::RightStickX);
if x.abs() < threshold {
let y = pad.value(Axis::RightStickY);
if x.abs() < threshold && y.abs() < threshold {
None
} else {
} else if x.abs() > y.abs() {
Some(if x > 0.0 { Action::SeekForward } else { Action::SeekBack })
} else {
Some(if y > 0.0 { Action::VolumeUp } else { Action::VolumeDown })
}
}
Source::DPad => None,
+23
View File
@@ -3,14 +3,21 @@ slint::include_modules!();
mod app;
mod config;
mod devscript;
mod inhibit;
mod input;
mod mpris;
mod palette;
mod player;
mod prompts;
mod saved_queue;
mod shuffle;
mod subsonic;
use std::time::Duration;
/// The Flatpak app id, which is also the name of the desktop file.
const APP_ID: &str = "me.anshorei.Fettleshed.Remus";
fn main() -> anyhow::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("remus=info")).init();
@@ -23,8 +30,24 @@ fn main() -> anyhow::Result<()> {
.build()?;
let ui = AppWindow::new()?;
// Docks match the window to the desktop file by this id, on Wayland as
// the app id and on X11 as the WM_CLASS. It needs the platform that
// AppWindow::new sets up, and has to be set before the window is shown.
slint::set_xdg_app_id(APP_ID)?;
ui.set_version(env!("CARGO_PKG_VERSION").into());
app::install(&ui, rt.handle().clone());
// The controller is read from the device, whichever window is in front, so
// the app needs to know when another one is, to leave the presses to it.
{
use slint::winit_030::{EventResult, WinitWindowAccessor, winit::event::WindowEvent};
ui.window().on_winit_window_event(|_, event| {
if let WindowEvent::Focused(focused) = *event {
log::debug!("window focused: {focused}");
app::with_app(move |app| app.set_window_active(focused));
}
EventResult::Propagate
});
}
input::spawn_gamepad(|ev| {
let _ = slint::invoke_from_event_loop(move || {
app::with_app(move |app| match ev {
+368
View File
@@ -0,0 +1,368 @@
//! MPRIS on the session bus, so the desktop's media controls and media keys
//! can drive playback. Headphone buttons arrive this way too: the desktop
//! turns the key events of a headset or a Bluetooth AVRCP device into calls
//! on the active MPRIS player. Reading those devices directly is not an
//! option, since keyboard-like input devices are root:input and only
//! gamepads are opened up to the logged-in user.
//!
//! A bus that cannot be reached, or a name already taken by another remus,
//! is logged once and otherwise ignored.
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::atomic::{AtomicI64, Ordering};
use anyhow::Result;
use tokio::runtime::Handle;
use tokio::sync::watch;
use zbus::interface;
use zbus::zvariant::{ObjectPath, OwnedValue, Value};
const BUS_NAME: &str = "org.mpris.MediaPlayer2.remus";
const PATH: &str = "/org/mpris/MediaPlayer2";
const DESKTOP_ENTRY: &str = "me.anshorei.Fettleshed.Remus";
/// What a client asked for.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Command {
PlayPause,
Play,
Pause,
Stop,
Next,
Previous,
Quit,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Status {
#[default]
Stopped,
Paused,
Playing,
}
impl Status {
fn as_str(self) -> &'static str {
match self {
Status::Stopped => "Stopped",
Status::Paused => "Paused",
Status::Playing => "Playing",
}
}
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Track {
/// Position in the queue, which makes the track id.
pub index: usize,
pub title: String,
pub artist: Option<String>,
pub album: Option<String>,
pub seconds: Option<u32>,
}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct NowPlaying {
pub status: Status,
pub track: Option<Track>,
/// 0 to 1, already muted to 0.
pub volume: f64,
}
pub struct Mpris {
state: watch::Sender<NowPlaying>,
position: Arc<AtomicI64>,
}
impl Mpris {
pub fn spawn(rt: &Handle, on_command: impl Fn(Command) + Send + Sync + 'static) -> Mpris {
let (state, rx) = watch::channel(NowPlaying::default());
let position = Arc::new(AtomicI64::new(0));
let pos = position.clone();
let on_command: Arc<dyn Fn(Command) + Send + Sync> = Arc::new(on_command);
rt.spawn(async move {
if let Err(e) = run(rx, pos, on_command).await {
log::warn!("MPRIS unavailable, media keys will not reach remus: {e:#}");
}
});
Mpris { state, position }
}
/// Publishes what is playing. Clients hear only about what changed.
pub fn update(&self, now: NowPlaying) {
self.state.send_if_modified(|s| {
let changed = *s != now;
*s = now;
changed
});
}
/// Clients read the position when they want it; it sends no signal.
pub fn set_position(&self, seconds: f64) {
self.position.store((seconds * 1e6) as i64, Ordering::Relaxed);
}
}
async fn run(
mut rx: watch::Receiver<NowPlaying>,
position: Arc<AtomicI64>,
on_command: Arc<dyn Fn(Command) + Send + Sync>,
) -> Result<()> {
let player = Player {
now: rx.borrow().clone(),
position,
on_command: on_command.clone(),
};
let conn = zbus::connection::Builder::session()?
.name(BUS_NAME)?
.serve_at(PATH, Root { on_command })?
.serve_at(PATH, player)?
.build()
.await?;
log::info!("MPRIS player registered as {BUS_NAME}");
let iface = conn.object_server().interface::<_, Player>(PATH).await?;
while rx.changed().await.is_ok() {
let now = rx.borrow_and_update().clone();
let mut p = iface.get_mut().await;
let status = p.now.status != now.status;
let track = p.now.track != now.track;
let volume = p.now.volume != now.volume;
p.now = now;
let emitter = iface.signal_emitter();
if status {
p.playback_status_changed(emitter).await?;
}
if track {
p.metadata_changed(emitter).await?;
p.can_play_changed(emitter).await?;
p.can_pause_changed(emitter).await?;
p.can_go_next_changed(emitter).await?;
p.can_go_previous_changed(emitter).await?;
}
if volume {
p.volume_changed(emitter).await?;
}
}
Ok(())
}
struct Root {
on_command: Arc<dyn Fn(Command) + Send + Sync>,
}
#[interface(name = "org.mpris.MediaPlayer2")]
impl Root {
fn raise(&self) {}
fn quit(&self) {
(self.on_command)(Command::Quit);
}
#[zbus(property)]
fn can_quit(&self) -> bool {
true
}
#[zbus(property)]
fn can_raise(&self) -> bool {
false
}
#[zbus(property)]
fn has_track_list(&self) -> bool {
false
}
#[zbus(property)]
fn identity(&self) -> &str {
"Remus"
}
#[zbus(property)]
fn desktop_entry(&self) -> &str {
DESKTOP_ENTRY
}
#[zbus(property)]
fn supported_uri_schemes(&self) -> Vec<String> {
Vec::new()
}
#[zbus(property)]
fn supported_mime_types(&self) -> Vec<String> {
Vec::new()
}
}
struct Player {
now: NowPlaying,
position: Arc<AtomicI64>,
on_command: Arc<dyn Fn(Command) + Send + Sync>,
}
#[interface(name = "org.mpris.MediaPlayer2.Player")]
impl Player {
fn play_pause(&self) {
(self.on_command)(Command::PlayPause);
}
fn play(&self) {
(self.on_command)(Command::Play);
}
fn pause(&self) {
(self.on_command)(Command::Pause);
}
fn stop(&self) {
(self.on_command)(Command::Stop);
}
fn next(&self) {
(self.on_command)(Command::Next);
}
fn previous(&self) {
(self.on_command)(Command::Previous);
}
// CanSeek is false, so clients do not call these; they are part of the
// interface all the same.
fn seek(&self, _offset: i64) {}
fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) {}
fn open_uri(&self, _uri: &str) {}
#[zbus(property)]
fn playback_status(&self) -> &str {
self.now.status.as_str()
}
#[zbus(property)]
fn rate(&self) -> f64 {
1.0
}
#[zbus(property)]
fn minimum_rate(&self) -> f64 {
1.0
}
#[zbus(property)]
fn maximum_rate(&self) -> f64 {
1.0
}
#[zbus(property)]
fn metadata(&self) -> HashMap<String, OwnedValue> {
metadata(self.now.track.as_ref())
}
#[zbus(property)]
fn volume(&self) -> f64 {
self.now.volume
}
#[zbus(property(emits_changed_signal = "false"))]
fn position(&self) -> i64 {
self.position.load(Ordering::Relaxed)
}
#[zbus(property)]
fn can_go_next(&self) -> bool {
self.now.track.is_some()
}
#[zbus(property)]
fn can_go_previous(&self) -> bool {
self.now.track.is_some()
}
#[zbus(property)]
fn can_play(&self) -> bool {
self.now.track.is_some()
}
#[zbus(property)]
fn can_pause(&self) -> bool {
self.now.track.is_some()
}
#[zbus(property)]
fn can_seek(&self) -> bool {
false
}
#[zbus(property(emits_changed_signal = "const"))]
fn can_control(&self) -> bool {
true
}
}
/// The MPRIS metadata map for a track, empty when nothing is loaded.
fn metadata(track: Option<&Track>) -> HashMap<String, OwnedValue> {
let mut m = HashMap::new();
let Some(t) = track else {
let none = ObjectPath::from_static_str_unchecked("/org/mpris/MediaPlayer2/TrackList/NoTrack");
insert(&mut m, "mpris:trackid", Value::from(none));
return m;
};
// Outside /org/mpris, which the spec reserves.
let id = format!("/me/anshorei/Fettleshed/Remus/track/{}", t.index);
if let Ok(path) = ObjectPath::try_from(id) {
insert(&mut m, "mpris:trackid", Value::from(path));
}
insert(&mut m, "xesam:title", Value::from(t.title.clone()));
if let Some(a) = &t.artist {
insert(&mut m, "xesam:artist", Value::from(vec![a.clone()]));
}
if let Some(a) = &t.album {
insert(&mut m, "xesam:album", Value::from(a.clone()));
}
if let Some(s) = t.seconds {
insert(&mut m, "mpris:length", Value::from(s as i64 * 1_000_000));
}
m
}
fn insert(m: &mut HashMap<String, OwnedValue>, key: &str, value: Value<'_>) {
if let Ok(v) = OwnedValue::try_from(value) {
m.insert(key.to_string(), v);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn metadata_without_a_track_says_so() {
let m = metadata(None);
assert_eq!(m.len(), 1);
let id: ObjectPath = m["mpris:trackid"].clone().try_into().unwrap();
assert_eq!(id.as_str(), "/org/mpris/MediaPlayer2/TrackList/NoTrack");
}
#[test]
fn metadata_carries_the_track() {
let t = Track {
index: 3,
title: "Feijão".into(),
artist: Some("Dr. Quandary".into()),
album: None,
seconds: Some(218),
};
let m = metadata(Some(&t));
let title: String = m["xesam:title"].clone().try_into().unwrap();
assert_eq!(title, "Feijão");
let artists: Vec<String> = m["xesam:artist"].clone().try_into().unwrap();
assert_eq!(artists, ["Dr. Quandary"]);
let length: i64 = m["mpris:length"].clone().try_into().unwrap();
assert_eq!(length, 218_000_000);
assert!(!m.contains_key("xesam:album"));
let id: ObjectPath = m["mpris:trackid"].clone().try_into().unwrap();
assert_eq!(id.as_str(), "/me/anshorei/Fettleshed/Remus/track/3");
}
}
+508 -38
View File
@@ -2,6 +2,7 @@
//! track can be handed to playbin in `about-to-finish`, which keeps playback
//! gapless.
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex, MutexGuard};
use std::thread::JoinHandle;
@@ -11,13 +12,35 @@ use anyhow::{Context, Result};
use gstreamer as gst;
use gstreamer::prelude::*;
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone)]
pub enum PlayerEvent {
Position(f64),
Duration(f64),
Paused(bool),
/// Index into the queue, None when playback has stopped.
Track(Option<usize>),
/// Index into the queue, None when playback has stopped. An index is
/// only valid for the queue `generation` it was sent from: see `reorder`.
Track {
index: Option<usize>,
generation: u64,
},
/// The picture embedded in the playing track's file, or None once it is
/// clear the file has none. Sent once per track started, after its
/// `Track`. A picture that turns up late is still sent, after the None.
Art {
index: usize,
generation: u64,
picture: Option<Vec<u8>>,
},
}
/// The queue after `reorder`.
#[derive(Debug, Clone, PartialEq)]
pub struct Reordered {
/// The new order, as positions in the old one.
pub perm: Vec<usize>,
pub current: Option<usize>,
pub pending: Option<usize>,
pub generation: u64,
}
#[derive(Default)]
@@ -26,16 +49,30 @@ struct Queue {
current: Option<usize>,
/// Handed to playbin, becomes `current` at its stream-start.
pending: Option<usize>,
/// Loaded paused by `load_paused` and not played since: a track that
/// fails is skipped without starting playback.
hold: bool,
/// Seconds to seek to once the paused track has prerolled.
seek_to: Option<f64>,
/// Bumped by every reorder, so an index sent before one is recognised.
generation: u64,
}
/// Pictures found in the files being decoded, by URI.
type Pictures = Arc<Mutex<HashMap<String, Vec<u8>>>>;
pub struct Player {
playbin: gst::Element,
queue: Arc<Mutex<Queue>>,
pictures: Pictures,
stop: Arc<AtomicBool>,
bus_thread: Option<JoinHandle<()>>,
}
const TICK: Duration = Duration::from_millis(250);
/// How long after a track starts its tags can still bring a picture. Tags
/// come ahead of the audio, so this is mostly a slow server's margin.
const ART_WAIT: Duration = Duration::from_millis(600);
impl Player {
pub fn spawn(on_event: impl Fn(PlayerEvent) + Send + 'static) -> Result<Player> {
@@ -66,15 +103,19 @@ impl Player {
None
});
let pictures = Pictures::default();
watch_pictures(&playbin, &pictures);
let stop = Arc::new(AtomicBool::new(false));
let bus_thread = std::thread::Builder::new().name("gst-bus".into()).spawn({
let (playbin, queue, stop) = (playbin.clone(), queue.clone(), stop.clone());
move || watch_bus(&playbin, &queue, &stop, &on_event)
let (playbin, queue, pictures, stop) = (playbin.clone(), queue.clone(), pictures.clone(), stop.clone());
move || watch_bus(&playbin, &queue, &pictures, &stop, &on_event)
})?;
Ok(Player {
playbin,
queue,
pictures,
stop,
bus_thread: Some(bus_thread),
})
@@ -91,6 +132,28 @@ impl Player {
self.play_index(start);
}
/// Reorders the queue without interrupting the playing track. `arrange`
/// gets the playing position and the one already handed to playbin, and
/// returns the new order as positions in the old one; a position it
/// leaves out is dropped. It runs under the queue lock, so no track
/// starts in between: keep the handed-over track right after the playing
/// one, or the queue jumps to wherever it went once it starts.
pub fn reorder(&self, arrange: impl FnOnce(Option<usize>, Option<usize>) -> Vec<usize>) -> Reordered {
let mut q = lock(&self.queue);
let perm = arrange(q.current, q.pending);
let moved = |i: Option<usize>| i.and_then(|i| perm.iter().position(|&p| p == i));
q.current = moved(q.current);
q.pending = moved(q.pending);
q.urls = perm.iter().filter_map(|&p| q.urls.get(p).cloned()).collect();
q.generation += 1;
Reordered {
current: q.current,
pending: q.pending,
generation: q.generation,
perm,
}
}
/// Adds to the end of the queue, starting playback if it had stopped.
pub fn append(&self, url: &str) {
let start = {
@@ -103,11 +166,34 @@ impl Player {
}
}
/// Replaces the queue with `urls` and readies `index` paused at
/// `position` seconds, so nothing plays until `toggle_pause`. With no
/// index the queue is only stored, as after it played to the end.
pub fn load_paused(&self, urls: &[String], index: Option<usize>, position: f64) {
let url = {
let mut q = lock(&self.queue);
q.urls = urls.to_vec();
q.current = None;
q.pending = None;
q.hold = false;
q.seek_to = None;
let Some(i) = index else { return };
let Some(url) = q.urls.get(i).cloned() else { return };
q.pending = Some(i);
q.hold = true;
q.seek_to = (position > 0.0).then_some(position);
url
};
start_paused(&self.playbin, &url);
}
pub fn play_index(&self, index: usize) {
let url = {
let mut q = lock(&self.queue);
let Some(url) = q.urls.get(index).cloned() else { return };
q.pending = Some(index);
q.hold = false;
q.seek_to = None;
url
};
// Not under the lock: a state change waits for the streaming threads,
@@ -115,12 +201,36 @@ impl Player {
start(&self.playbin, &url);
}
/// Stops playback and forgets the queue, as when switching server. Going
/// to Null flushes the bus, so nothing from the old track reports later.
pub fn stop(&self) {
let mut q = lock(&self.queue);
*q = Queue {
generation: q.generation,
..Queue::default()
};
drop(q);
lock(&self.pictures).clear();
let _ = self.playbin.set_state(gst::State::Null);
}
pub fn toggle_pause(&self) {
let target = match self.playbin.current_state() {
// Toggles where the pipeline is heading, so play pressed while a
// paused track is still loading is not lost.
let (_, current, pending) = self.playbin.state(gst::ClockTime::ZERO);
let heading = if pending == gst::State::VoidPending {
current
} else {
pending
};
let target = match heading {
gst::State::Playing => gst::State::Paused,
gst::State::Paused => gst::State::Playing,
_ => return,
};
if target == gst::State::Playing {
lock(&self.queue).hold = false;
}
let _ = self.playbin.set_state(target);
}
@@ -138,21 +248,22 @@ impl Player {
}
}
/// Sets remus's own playback volume, 0 to 100. Cubic, so equal steps
/// sound equally loud apart.
pub fn set_volume(&self, level: u8) {
let v = level.min(100) as f64 / 100.0;
self.playbin.set_property("volume", v * v * v);
}
pub fn set_muted(&self, muted: bool) {
self.playbin.set_property("mute", muted);
}
pub fn seek(&self, seconds: f64) {
let Some(pos) = self.playbin.query_position::<gst::ClockTime>() else {
return;
};
let mut target = (pos.seconds_f64() + seconds).max(0.0);
if let Some(dur) = self.playbin.query_duration::<gst::ClockTime>() {
target = target.min((dur.seconds_f64() - 1.0).max(0.0));
}
let flags = gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT;
if let Err(e) = self
.playbin
.seek_simple(flags, gst::ClockTime::from_seconds_f64(target))
{
log::debug!("seek failed: {e}");
}
seek_to(&self.playbin, pos.seconds_f64() + seconds);
}
}
@@ -166,8 +277,53 @@ impl Drop for Player {
}
}
fn lock(q: &Mutex<Queue>) -> MutexGuard<'_, Queue> {
q.lock().unwrap_or_else(|e| e.into_inner())
fn lock<T>(m: &Mutex<T>) -> MutexGuard<'_, T> {
m.lock().unwrap_or_else(|e| e.into_inner())
}
/// Records the picture in each file playbin decodes, keyed by its URI. Read
/// where each file's decoder hands on its stream, because further down the
/// tags of a file without a picture still carry the previous file's, once
/// playback moves on gaplessly.
fn watch_pictures(playbin: &gst::Element, pictures: &Pictures) {
let Some(bin) = playbin.downcast_ref::<gst::Bin>() else {
return;
};
let pictures = pictures.clone();
bin.connect_deep_element_added(move |_, _, element| {
let decoder = element
.factory()
.is_some_and(|f| matches!(f.name().as_str(), "uridecodebin" | "uridecodebin3"));
// playbin adds the same decoder again for later tracks.
// SAFETY: the key is only ever set to a bool, here.
if !decoder || unsafe { element.data::<bool>("remus-pictures") }.is_some() {
return;
}
unsafe { element.set_data("remus-pictures", true) };
let pictures = pictures.clone();
element.connect_pad_added(move |decoder, pad| {
let decoder = decoder.downgrade();
let pictures = pictures.clone();
pad.add_probe(gst::PadProbeType::EVENT_DOWNSTREAM, move |_, info| {
if let Some(gst::PadProbeData::Event(ev)) = &info.data
&& let gst::EventView::Tag(t) = ev.view()
&& let Some(bytes) = embedded_picture(t.tag())
&& let Some(uri) = decoder.upgrade().and_then(|d| d.property::<Option<String>>("uri"))
{
lock(&pictures).entry(uri).or_insert(bytes);
}
gst::PadProbeReturn::Ok
});
});
});
}
/// The track whose picture is still being looked for.
struct ArtWait {
url: String,
since: Instant,
/// Already reported as without a picture; one turning up later is still sent.
told_none: bool,
}
fn start(playbin: &gst::Element, url: &str) {
@@ -178,27 +334,59 @@ fn start(playbin: &gst::Element, url: &str) {
}
}
fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, emit: &dyn Fn(PlayerEvent)) {
fn start_paused(playbin: &gst::Element, url: &str) {
let _ = playbin.set_state(gst::State::Ready);
playbin.set_property("uri", url);
if let Err(e) = playbin.set_state(gst::State::Paused) {
log::warn!("could not load the track: {e}");
}
}
/// Seeks to `seconds`, kept a second short of the end so a stale position
/// does not land past a track that has since changed.
fn seek_to(playbin: &gst::Element, seconds: f64) {
let mut target = seconds.max(0.0);
if let Some(dur) = playbin.query_duration::<gst::ClockTime>() {
target = target.min((dur.seconds_f64() - 1.0).max(0.0));
}
let flags = gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT;
if let Err(e) = playbin.seek_simple(flags, gst::ClockTime::from_seconds_f64(target)) {
log::debug!("seek failed: {e}");
}
}
fn watch_bus(
playbin: &gst::Element,
queue: &Mutex<Queue>,
pictures: &Pictures,
stop: &AtomicBool,
emit: &dyn Fn(PlayerEvent),
) {
let Some(bus) = playbin.bus() else { return };
let mut last_tick = Instant::now();
let mut duration = 0.0;
// playbin can post stream-start more than once for one track, so a repeat
// of the last report is dropped. A track that was just started is always
// reported, even at the same index: a new queue, or the same track again.
let mut last_track: Option<Option<usize>> = None;
let mut report_track = |t: Option<usize>, started: bool| {
if started || last_track != Some(t) {
last_track = Some(t);
emit(PlayerEvent::Track(t));
// reported, even the same one: a new queue, or the same track again. By
// URL, since a reorder moves the track without restarting it.
let mut last_track: Option<Option<String>> = None;
let mut report_track = |index: Option<usize>, url: Option<String>, generation: u64, started: bool| {
if started || last_track.as_ref() != Some(&url) {
last_track = Some(url);
emit(PlayerEvent::Track { index, generation });
emit(PlayerEvent::Position(0.0));
true
} else {
false
}
};
let mut art_wait: Option<ArtWait> = None;
while !stop.load(Ordering::Relaxed) {
if let Some(msg) = bus.timed_pop(gst::ClockTime::from_mseconds(TICK.as_millis() as u64)) {
use gst::MessageView;
match msg.view() {
MessageView::StreamStart(_) => {
let (current, started) = {
let (current, url, generation, started) = {
let mut q = lock(queue);
let started = match q.pending.take() {
Some(p) => {
@@ -207,34 +395,72 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
}
None => false,
};
(q.current, started)
let url = q.current.and_then(|i| q.urls.get(i).cloned());
(q.current, url, q.generation, started)
};
duration = 0.0;
report_track(current, started);
if report_track(current, url.clone(), generation, started) {
art_wait = url.map(|url| ArtWait {
url,
since: Instant::now(),
told_none: false,
});
// Keep only what this track and the next may still need.
let keep: Vec<String> = {
let q = lock(queue);
current
.into_iter()
.flat_map(|i| q.urls.get(i..=i + 1))
.flatten()
.cloned()
.collect()
};
lock(pictures).retain(|uri, _| keep.contains(uri));
}
}
MessageView::StateChanged(s) if s.src() == Some(playbin.upcast_ref()) => match s.current() {
gst::State::Playing => emit(PlayerEvent::Paused(false)),
gst::State::Paused if s.pending() == gst::State::VoidPending => emit(PlayerEvent::Paused(true)),
_ => {}
},
// Prerolled: the first moment a paused track can seek, and the
// ticks below report no position while paused, so report it here.
MessageView::AsyncDone(_) => {
let target = lock(queue).seek_to.take();
if let Some(s) = target {
seek_to(playbin, s);
} else if let Some(p) = playbin.query_position::<gst::ClockTime>() {
emit(PlayerEvent::Position(p.seconds_f64()));
}
}
MessageView::Eos(_) => {
{
let mut q = lock(queue);
q.current = None;
q.pending = None;
}
let generation = lock(queue).generation;
let _ = playbin.set_state(gst::State::Ready);
report_track(None, false);
report_track(None, None, generation, false);
art_wait = None;
}
// A failing source posts several errors. Once the first has moved
// on to the next track, the source is out of playbin and the rest
// would count as the next track failing too.
MessageView::Error(err) if err.src().is_some_and(|s| !s.has_as_ancestor(playbin)) => {
log::debug!("dropping an error from a track already skipped: {}", err.error());
}
MessageView::Error(err) => {
let detail = err.debug().map(|d| d.to_string()).unwrap_or_default();
log::warn!("playback error: {} ({})", err.error(), strip_queries(&detail));
// Skip the track that failed rather than stopping the queue.
let (next, len) = {
let (next, len, hold) = {
let mut q = lock(queue);
let failed = q.pending.take().or(q.current);
q.current = None;
(failed.map_or(usize::MAX, |i| i + 1), q.urls.len())
// The position belonged to the track that failed.
q.seek_to = None;
(failed.map_or(usize::MAX, |i| i + 1), q.urls.len(), q.hold)
};
if next < len {
let url = {
@@ -242,15 +468,50 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
q.pending = Some(next);
q.urls[next].clone()
};
start(playbin, &url);
if hold {
start_paused(playbin, &url);
} else {
start(playbin, &url);
}
} else {
let generation = lock(queue).generation;
let _ = playbin.set_state(gst::State::Ready);
report_track(None, false);
report_track(None, None, generation, false);
art_wait = None;
}
}
_ => {}
}
}
if let Some(w) = &mut art_wait {
// Where the track is now, since a reorder may have moved it.
let (index, generation) = {
let q = lock(queue);
let index = q.current.filter(|&i| q.urls.get(i) == Some(&w.url));
(index, q.generation)
};
let picture = lock(pictures).get(&w.url).cloned();
match index {
None => art_wait = None,
Some(index) if picture.is_some() => {
emit(PlayerEvent::Art {
index,
generation,
picture,
});
art_wait = None;
}
Some(index) if !w.told_none && w.since.elapsed() >= ART_WAIT => {
w.told_none = true;
emit(PlayerEvent::Art {
index,
generation,
picture: None,
});
}
Some(_) => {}
}
}
if last_tick.elapsed() >= TICK {
last_tick = Instant::now();
if playbin.current_state() == gst::State::Playing {
@@ -268,6 +529,22 @@ fn watch_bus(playbin: &gst::Element, queue: &Mutex<Queue>, stop: &AtomicBool, em
}
}
/// The front cover among the pictures in `tags`, else the first picture.
fn embedded_picture(tags: &gst::TagListRef) -> Option<Vec<u8>> {
// GST_TAG_IMAGE_TYPE_FRONT_COVER in gst-tag's GstTagImageType.
const FRONT_COVER: i32 = 1;
let is_front = |s: &gst::Sample| {
s.info()
.and_then(|i| i.value("image-type").ok())
.and_then(|v| gst::glib::EnumValue::from_value(v))
.is_some_and(|(_, v)| v.value() == FRONT_COVER)
};
let pictures: Vec<gst::Sample> = tags.iter_tag::<gst::tags::Image>().map(|v| v.get()).collect();
let sample = pictures.iter().find(|s| is_front(s)).or(pictures.first())?;
let map = sample.buffer()?.map_readable().ok()?;
Some(map.as_slice().to_vec())
}
/// Removes the query string from any URL in `text`. Stream URLs carry the
/// Subsonic auth token, and GStreamer's HTTP errors quote the URL.
fn strip_queries(text: &str) -> String {
@@ -335,6 +612,57 @@ mod tests {
format!("file://{}", path.display())
}
/// Puts an ID3v2.3 tag holding `picture` as the front cover before the
/// file at `uri`, as a tagged MP3 would carry it.
fn with_id3_picture(uri: &str, picture: &[u8]) {
let path = uri.strip_prefix("file://").unwrap();
let mut body = vec![0u8]; // Latin-1 text
body.extend_from_slice(b"image/png\0");
body.push(3); // front cover
body.push(0); // empty description
body.extend_from_slice(picture);
let mut frame = b"APIC".to_vec();
frame.extend_from_slice(&(body.len() as u32).to_be_bytes());
frame.extend_from_slice(&[0, 0]);
frame.extend_from_slice(&body);
let n = frame.len() as u32;
let syncsafe = [(n >> 21) & 0x7f, (n >> 14) & 0x7f, (n >> 7) & 0x7f, n & 0x7f].map(|b| b as u8);
let mut tagged = b"ID3\x03\x00\x00".to_vec();
tagged.extend_from_slice(&syncsafe);
tagged.extend_from_slice(&frame);
tagged.extend_from_slice(&std::fs::read(path).unwrap());
std::fs::write(path, tagged).unwrap();
}
#[test]
fn reports_the_picture_in_each_file() {
// SAFETY: set before any thread reads the environment in this test.
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
let dir = std::env::temp_dir().join(format!("remus-player-art-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let urls = vec![silent_wav(&dir, "a.wav", 1.0), silent_wav(&dir, "b.wav", 1.0)];
let mut png = Vec::new();
image::RgbImage::from_pixel(4, 4, image::Rgb([200, 30, 30]))
.write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png)
.unwrap();
with_id3_picture(&urls[0], &png);
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Art { index, picture, .. } = ev {
let _ = tx.send((index, picture));
}
})
.unwrap();
player.play_list(&urls, 0);
let first = rx.recv_timeout(Duration::from_secs(5));
let second = rx.recv_timeout(Duration::from_secs(5));
drop(player);
let _ = std::fs::remove_dir_all(&dir);
assert_eq!(first, Ok((0, Some(png))), "the tagged file's picture");
assert_eq!(second, Ok((1, None)), "the plain file has none");
}
#[test]
fn plays_a_queue_through_to_the_end() {
// SAFETY: set before any thread reads the environment in this test.
@@ -345,8 +673,8 @@ mod tests {
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Track(t) = ev {
let _ = tx.send(t);
if let PlayerEvent::Track { index, .. } = ev {
let _ = tx.send(index);
}
})
.unwrap();
@@ -376,8 +704,8 @@ mod tests {
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Track(t) = ev {
let _ = tx.send(t);
if let PlayerEvent::Track { index, .. } = ev {
let _ = tx.send(index);
}
})
.unwrap();
@@ -395,4 +723,146 @@ mod tests {
drop(player);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn a_paused_load_seeks_and_waits_for_play() {
// SAFETY: set before any thread reads the environment in this test.
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
let dir = std::env::temp_dir().join(format!("remus-player-paused-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
// The saved track no longer exists, so the next one is readied instead.
let missing = format!("file://{}", dir.join("gone.wav").display());
let urls = vec![
silent_wav(&dir, "a.wav", 10.0),
missing,
silent_wav(&dir, "c.wav", 10.0),
];
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
let _ = tx.send(ev);
})
.unwrap();
player.load_paused(&urls, Some(1), 5.0);
let mut track = None;
let mut started = false;
let deadline = Instant::now() + Duration::from_secs(2);
while let Some(left) = deadline.checked_duration_since(Instant::now()) {
match rx.recv_timeout(left) {
Ok(PlayerEvent::Track { index, .. }) => track = index,
Ok(PlayerEvent::Paused(false)) => started = true,
Ok(PlayerEvent::Position(p)) if p > 0.0 => started = true,
Ok(_) => {}
Err(_) => break,
}
}
assert_eq!(track, Some(2), "skipped the missing track");
assert!(!started, "nothing plays before play is pressed");
player.toggle_pause();
let mut played = false;
while let Ok(ev) = rx.recv_timeout(Duration::from_secs(3)) {
if let PlayerEvent::Position(p) = ev
&& p > 0.0
{
played = true;
// The seek was dropped with the track it belonged to.
assert!(p < 4.0, "position {p}");
break;
}
}
assert!(played, "plays once play is pressed");
player.load_paused(&urls, Some(0), 5.0);
player.toggle_pause();
let mut pos = None;
while let Ok(ev) = rx.recv_timeout(Duration::from_secs(3)) {
if let PlayerEvent::Position(p) = ev
&& p > 0.0
{
pos = Some(p);
break;
}
}
let p = pos.expect("a position once playing");
assert!((4.5..7.0).contains(&p), "resumed at {p}");
drop(player);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn a_reorder_keeps_the_track_playing_and_plays_the_new_order() {
// SAFETY: set before any thread reads the environment in this test.
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
let dir = std::env::temp_dir().join(format!("remus-player-reorder-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let urls = vec![
silent_wav(&dir, "a.wav", 0.8),
silent_wav(&dir, "b.wav", 0.6),
silent_wav(&dir, "c.wav", 0.6),
];
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Track { index, generation } = ev {
let _ = tx.send((index, generation));
}
})
.unwrap();
player.play_list(&urls, 0);
assert_eq!(rx.recv_timeout(Duration::from_secs(5)), Ok((Some(0), 0)));
let r = player.reorder(|current, pending| {
assert_eq!((current, pending), (Some(0), None));
vec![0, 2, 1]
});
assert_eq!((r.current, r.pending, r.generation), (Some(0), None, 1));
let mut tracks = Vec::new();
let mut played = Vec::new();
while let Ok((t, generation)) = rx.recv_timeout(Duration::from_secs(5)) {
assert_eq!(generation, 1);
tracks.push(t);
played.extend(t.map(|i| lock(&player.queue).urls[i].clone()));
if t.is_none() {
break;
}
}
drop(player);
let _ = std::fs::remove_dir_all(&dir);
assert_eq!(tracks, vec![Some(1), Some(2), None], "a did not start again");
assert_eq!(played, vec![urls[2].clone(), urls[1].clone()]);
}
#[test]
fn a_reorder_can_drop_tracks_before_the_playing_one() {
// SAFETY: set before any thread reads the environment in this test.
unsafe { std::env::set_var("REMUS_AUDIO_SINK", "fakesink") };
let dir = std::env::temp_dir().join(format!("remus-player-trim-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let urls: Vec<String> = ["a", "b", "c"]
.iter()
.map(|n| silent_wav(&dir, &format!("{n}.wav"), 10.0))
.collect();
let (tx, rx) = mpsc::channel();
let player = Player::spawn(move |ev| {
if let PlayerEvent::Track { index, .. } = ev {
let _ = tx.send(index);
}
})
.unwrap();
player.play_list(&urls, 1);
assert_eq!(rx.recv_timeout(Duration::from_secs(3)), Ok(Some(1)));
let r = player.reorder(|_, _| vec![1, 2]);
assert_eq!(r.current, Some(0));
player.next();
assert_eq!(rx.recv_timeout(Duration::from_secs(3)), Ok(Some(1)));
assert_eq!(lock(&player.queue).urls, urls[1..]);
drop(player);
let _ = std::fs::remove_dir_all(&dir);
}
}
+32 -1
View File
@@ -33,6 +33,13 @@ pub enum Control {
Search,
NowPlaying,
Seek,
Volume,
Mute,
/// Cycles the shuffle mode on now playing: the queue button on a
/// controller, a key of its own on the keyboard.
Shuffle,
/// Shuffle play on a row: a long press of activate on a controller.
ShufflePlay,
/// Steam + X brings up Steam's on-screen keyboard. Nothing to show for a
/// real keyboard.
OnScreenKeyboard,
@@ -40,7 +47,7 @@ pub enum Control {
#[cfg(test)]
impl Control {
pub const ALL: [Control; 10] = [
pub const ALL: [Control; 14] = [
Control::Activate,
Control::Back,
Control::PlayPause,
@@ -50,6 +57,10 @@ impl Control {
Control::Search,
Control::NowPlaying,
Control::Seek,
Control::Volume,
Control::Mute,
Control::Shuffle,
Control::ShufflePlay,
Control::OnScreenKeyboard,
];
}
@@ -75,25 +86,35 @@ pub fn icons(prompts: Prompts, control: Control) -> &'static [&'static [u8]] {
Search => &[icon!("keyboard", "keyboard_slash_forward")],
NowPlaying => &[icon!("keyboard", "keyboard_f")],
Seek => &[icon!("keyboard", "keyboard_arrows_horizontal")],
Volume => &[icon!("keyboard", "keyboard_minus"), icon!("keyboard", "keyboard_plus")],
Mute => &[icon!("keyboard", "keyboard_m")],
Shuffle => &[icon!("keyboard", "keyboard_s")],
ShufflePlay => &[icon!("keyboard", "keyboard_shift"), icon!("keyboard", "keyboard_s")],
OnScreenKeyboard => &[],
},
Prompts::Pad(Family::Xbox) => match control {
Activate => &[icon!("xbox", "xbox_button_color_a")],
ShufflePlay => &[icon!("xbox", "xbox_button_color_a")],
Back => &[icon!("xbox", "xbox_button_color_b")],
PlayPause => &[icon!("xbox", "xbox_button_color_x")],
Queue => &[icon!("xbox", "xbox_button_color_y")],
Shuffle => &[icon!("xbox", "xbox_button_color_y")],
Skip => &[icon!("xbox", "xbox_lb"), icon!("xbox", "xbox_rb")],
Sections => &[icon!("xbox", "xbox_lt"), icon!("xbox", "xbox_rt")],
Search => &[icon!("xbox", "xbox_button_view")],
NowPlaying => &[icon!("xbox", "xbox_button_menu")],
Seek => &[icon!("xbox", "xbox_dpad_horizontal")],
Volume => &[icon!("xbox", "xbox_stick_r_vertical")],
Mute => &[icon!("xbox", "xbox_stick_r_press")],
OnScreenKeyboard => &[icon!("xbox", "xbox_guide"), icon!("xbox", "xbox_button_color_x")],
},
Prompts::Pad(Family::PlayStation) => match control {
Activate => &[icon!("playstation", "playstation_button_color_cross")],
ShufflePlay => &[icon!("playstation", "playstation_button_color_cross")],
Back => &[icon!("playstation", "playstation_button_color_circle")],
PlayPause => &[icon!("playstation", "playstation_button_color_square")],
Queue => &[icon!("playstation", "playstation_button_color_triangle")],
Shuffle => &[icon!("playstation", "playstation_button_color_triangle")],
Skip => &[
icon!("playstation", "playstation_trigger_l1"),
icon!("playstation", "playstation_trigger_r1"),
@@ -105,6 +126,8 @@ pub fn icons(prompts: Prompts, control: Control) -> &'static [&'static [u8]] {
Search => &[icon!("playstation", "playstation5_button_create")],
NowPlaying => &[icon!("playstation", "playstation5_button_options")],
Seek => &[icon!("playstation", "playstation_dpad_horizontal")],
Volume => &[icon!("playstation", "playstation_stick_r_vertical")],
Mute => &[icon!("playstation", "playstation_stick_r_press")],
// The pack has no PS button; Steam's own label says the same thing.
OnScreenKeyboard => &[
icon!("steamdeck", "steamdeck_button_guide"),
@@ -114,14 +137,18 @@ pub fn icons(prompts: Prompts, control: Control) -> &'static [&'static [u8]] {
// By position, as gilrs reports buttons: the bottom face button is B on a Switch.
Prompts::Pad(Family::Switch) => match control {
Activate => &[icon!("switch", "switch_button_b")],
ShufflePlay => &[icon!("switch", "switch_button_b")],
Back => &[icon!("switch", "switch_button_a")],
PlayPause => &[icon!("switch", "switch_button_y")],
Queue => &[icon!("switch", "switch_button_x")],
Shuffle => &[icon!("switch", "switch_button_x")],
Skip => &[icon!("switch", "switch_button_l"), icon!("switch", "switch_button_r")],
Sections => &[icon!("switch", "switch_button_zl"), icon!("switch", "switch_button_zr")],
Search => &[icon!("switch", "switch_button_minus")],
NowPlaying => &[icon!("switch", "switch_button_plus")],
Seek => &[icon!("switch", "switch_dpad_horizontal")],
Volume => &[icon!("switch", "switch_stick_r_vertical")],
Mute => &[icon!("switch", "switch_stick_r_press")],
OnScreenKeyboard => &[
icon!("switch", "switch_button_home"),
icon!("switch", "switch_button_y"),
@@ -129,9 +156,11 @@ pub fn icons(prompts: Prompts, control: Control) -> &'static [&'static [u8]] {
},
Prompts::Pad(Family::SteamDeck) => match control {
Activate => &[icon!("steamdeck", "steamdeck_button_a")],
ShufflePlay => &[icon!("steamdeck", "steamdeck_button_a")],
Back => &[icon!("steamdeck", "steamdeck_button_b")],
PlayPause => &[icon!("steamdeck", "steamdeck_button_x")],
Queue => &[icon!("steamdeck", "steamdeck_button_y")],
Shuffle => &[icon!("steamdeck", "steamdeck_button_y")],
Skip => &[
icon!("steamdeck", "steamdeck_button_l1"),
icon!("steamdeck", "steamdeck_button_r1"),
@@ -143,6 +172,8 @@ pub fn icons(prompts: Prompts, control: Control) -> &'static [&'static [u8]] {
Search => &[icon!("steamdeck", "steamdeck_button_view")],
NowPlaying => &[icon!("steamdeck", "steamdeck_button_options")],
Seek => &[icon!("steamdeck", "steamdeck_dpad_horizontal")],
Volume => &[icon!("steamdeck", "steamdeck_stick_r_vertical")],
Mute => &[icon!("steamdeck", "steamdeck_stick_r_press")],
OnScreenKeyboard => &[
icon!("steamdeck", "steamdeck_button_guide"),
icon!("steamdeck", "steamdeck_button_x"),
+220
View File
@@ -0,0 +1,220 @@
//! The queue saved to disk, so a restart picks up where playback was.
//!
//! One file holds a queue per server, keyed by user and server address. It
//! stores song ids and what is needed to draw the queue, never a stream URL:
//! those carry the token or the password, and are rebuilt from the client.
use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use crate::config;
use crate::shuffle::{Library, Mode};
use crate::subsonic::{Client, Song};
const VERSION: u32 = 1;
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SavedQueue {
/// In the order they play.
pub songs: Vec<Song>,
/// Each song's position in the order it was queued. Empty in files from
/// before shuffle, which were saved in that order.
#[serde(default)]
pub order: Vec<usize>,
#[serde(default)]
pub shuffle: Mode,
#[serde(default)]
pub library: Option<Library>,
pub current: Option<usize>,
/// Seconds into the current song.
pub position: f64,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SavedQueues {
version: u32,
servers: BTreeMap<String, SavedQueue>,
}
impl Default for SavedQueues {
fn default() -> Self {
SavedQueues {
version: VERSION,
servers: BTreeMap::new(),
}
}
}
impl SavedQueues {
pub fn get(&self, client: &Client) -> Option<&SavedQueue> {
self.servers.get(&key(client))
}
pub fn set(&mut self, client: &Client, queue: SavedQueue) {
self.servers.insert(key(client), queue);
}
/// Drops the queue of a forgotten server, by its address as
/// `Client::base` gives it. Returns whether there was one.
pub fn forget(&mut self, base: &str, user: &str) -> bool {
self.servers.remove(&key_of(base, user)).is_some()
}
}
/// Song ids are only unique within one server, and two users of a server
/// have their own queues.
fn key(client: &Client) -> String {
key_of(client.base(), client.user())
}
fn key_of(base: &str, user: &str) -> String {
format!("{user}@{base}")
}
pub fn path() -> Option<PathBuf> {
config::state_dir().map(|d| d.join("queue.json"))
}
/// The saved queues, or none when there is no file or it cannot be read.
/// A bad file is logged and left for the next save to replace.
pub fn load(path: &Path) -> SavedQueues {
let text = match fs::read_to_string(path) {
Ok(text) => text,
Err(e) if e.kind() == std::io::ErrorKind::NotFound => return SavedQueues::default(),
Err(e) => {
log::warn!("reading {}: {e}", path.display());
return SavedQueues::default();
}
};
match serde_json::from_str::<SavedQueues>(&text) {
Ok(q) if q.version == VERSION => q,
Ok(q) => {
log::warn!("ignoring {}: unknown version {}", path.display(), q.version);
SavedQueues::default()
}
Err(e) => {
log::warn!("ignoring {}: {e}", path.display());
SavedQueues::default()
}
}
}
pub fn save(path: &Path, queues: &SavedQueues) -> Result<()> {
config::write_atomic(path, &serde_json::to_string(queues)?)
}
#[cfg(test)]
mod tests {
use super::*;
use crate::subsonic::Auth;
fn song(id: &str) -> Song {
serde_json::from_value(serde_json::json!({
"id": id, "title": format!("Song {id}"), "artist": "A", "album": "B",
"coverArt": "al-1", "duration": 200, "track": 1,
}))
.unwrap()
}
fn temp(name: &str) -> PathBuf {
let dir = std::env::temp_dir().join(format!("remus-queue-{name}-{}", std::process::id()));
let _ = fs::remove_dir_all(&dir);
dir.join("queue.json")
}
#[test]
fn round_trips_a_queue_per_server() {
let path = temp("round-trip");
let home = Client::new("https://home", "u", Auth::Password("secret-pass".into()));
let other = Client::new(
"https://other",
"u",
Auth::Token {
salt: "s".into(),
token: "secret-token".into(),
},
);
let mut queues = SavedQueues::default();
let a = SavedQueue {
songs: vec![song("1"), song("2")],
order: vec![1, 0],
shuffle: Mode::Tracks,
library: Some(Library { added_end: 1 }),
current: Some(1),
position: 93.5,
};
let b = SavedQueue {
songs: vec![song("9")],
current: None,
position: 0.0,
..SavedQueue::default()
};
queues.set(&home, a.clone());
queues.set(&other, b.clone());
save(&path, &queues).unwrap();
let back = load(&path);
assert_eq!(back.get(&home), Some(&a));
assert_eq!(back.get(&other), Some(&b));
let text = fs::read_to_string(&path).unwrap();
assert!(!text.contains("secret") && !text.contains("stream"), "{text}");
let _ = fs::remove_dir_all(path.parent().unwrap());
}
#[test]
fn forgetting_a_server_drops_only_its_queue() {
let home = Client::new("https://home", "u", Auth::Password("p".into()));
let other = Client::new("https://other", "u", Auth::Password("p".into()));
let mut queues = SavedQueues::default();
queues.set(&home, SavedQueue::default());
queues.set(&other, SavedQueue::default());
assert!(queues.forget(home.base(), home.user()));
assert!(!queues.forget(home.base(), home.user()));
assert!(queues.get(&home).is_none());
assert!(queues.get(&other).is_some());
}
#[test]
fn a_queue_saved_before_shuffle_loads_unshuffled() {
let path = temp("before-shuffle");
fs::create_dir_all(path.parent().unwrap()).unwrap();
let client = Client::new("https://h", "u", Auth::Password("p".into()));
let text = r#"{"version": 1, "servers": {"u@https://h": {
"songs": [{"id": "1", "title": "One"}], "current": 0, "position": 12.0}}}"#;
fs::write(&path, text).unwrap();
let q = load(&path).get(&client).cloned().expect("the queue");
assert_eq!(
(q.songs.len(), q.order, q.shuffle, q.library),
(1, vec![], Mode::Off, None)
);
assert_eq!(q.songs[0].album_id, None);
let _ = fs::remove_dir_all(path.parent().unwrap());
}
#[test]
fn an_unreadable_file_loads_as_empty() {
let path = temp("unreadable");
fs::create_dir_all(path.parent().unwrap()).unwrap();
let client = Client::new("https://h", "u", Auth::Password("p".into()));
for text in ["{ not json", "{\"version\": 99, \"servers\": {}}", ""] {
fs::write(&path, text).unwrap();
assert_eq!(load(&path).get(&client), None, "{text:?}");
}
// A directory in its place cannot be read as a file at all.
fs::remove_file(&path).unwrap();
fs::create_dir(&path).unwrap();
assert_eq!(load(&path).get(&client), None);
let _ = fs::remove_dir_all(path.parent().unwrap());
}
#[test]
fn a_missing_file_loads_as_empty() {
let path = temp("missing");
assert_eq!(load(&path), SavedQueues::default());
}
}
+348
View File
@@ -0,0 +1,348 @@
//! Shuffled play orders. Every function returns a permutation: positions into
//! the queue as it plays now, in the order it should play next. The caller
//! applies the same permutation to the songs, to their original positions and
//! to the player's URLs, so the three never disagree.
//!
//! `fixed` is how many tracks at the head of the queue stay where they are:
//! those played, the one playing and one already handed to playbin.
use std::collections::HashMap;
use fastrand::Rng;
use serde::{Deserialize, Serialize};
use crate::subsonic::Song;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Mode {
#[default]
Off,
Tracks,
Albums,
}
impl Mode {
pub fn next(self) -> Mode {
match self {
Mode::Off => Mode::Tracks,
Mode::Tracks => Mode::Albums,
Mode::Albums => Mode::Off,
}
}
}
/// Library shuffle: the queue is topped up with random tracks from the
/// server as it runs low.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Library {
/// Where the random tracks carry on after those queued by hand, which go
/// after the playing track and after any queued before them.
pub added_end: usize,
}
/// Which album a song belongs to. The album name alone would merge different
/// albums of the same title, so it is only the fallback for songs saved
/// without an album id. A song with neither is an album of its own.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum AlbumKey<'a> {
Id(&'a str),
Name(&'a str, Option<&'a str>),
Alone(usize),
}
fn album_key(song: &Song, pos: usize) -> AlbumKey<'_> {
match (&song.album_id, &song.album) {
(Some(id), _) => AlbumKey::Id(id),
(None, Some(name)) if !name.is_empty() => AlbumKey::Name(name, song.artist.as_deref()),
_ => AlbumKey::Alone(pos),
}
}
/// Keeps the first `fixed` tracks and shuffles the rest.
pub fn tracks(rng: &mut Rng, len: usize, fixed: usize) -> Vec<usize> {
let fixed = fixed.min(len);
let mut perm: Vec<usize> = (0..len).collect();
rng.shuffle(&mut perm[fixed..]);
perm
}
/// Keeps the first `fixed` tracks, then plays the rest of the playing track's
/// album, then the other albums in random order. Each album plays in disc and
/// track order, and tracks without numbers keep their original order.
/// `original` holds each track's position in the original order.
pub fn albums(rng: &mut Rng, songs: &[Song], original: &[usize], playing: Option<usize>, fixed: usize) -> Vec<usize> {
let fixed = fixed.min(songs.len());
let mut groups = album_groups(songs, original, fixed..songs.len());
let first = playing
.and_then(|p| songs.get(p).map(|s| album_key(s, p)))
.and_then(|key| groups.iter().position(|(k, _)| *k == key))
.map(|i| groups.remove(i));
rng.shuffle(&mut groups);
(0..fixed)
.chain(first.into_iter().chain(groups).flat_map(|(_, g)| g))
.collect()
}
/// The tracks in `range` grouped by album, in the order each album first
/// appears, each sorted by disc and track.
fn album_groups<'a>(
songs: &'a [Song],
original: &[usize],
range: std::ops::Range<usize>,
) -> Vec<(AlbumKey<'a>, Vec<usize>)> {
let mut groups: Vec<(AlbumKey<'a>, Vec<usize>)> = Vec::new();
let mut index: HashMap<AlbumKey<'a>, usize> = HashMap::new();
for pos in range {
let key = album_key(&songs[pos], pos);
let i = *index.entry(key.clone()).or_insert_with(|| {
groups.push((key, Vec::new()));
groups.len() - 1
});
groups[i].1.push(pos);
}
for (_, g) in &mut groups {
g.sort_by_key(|&p| {
let s = &songs[p];
(
s.disc_number.unwrap_or(0),
s.track.unwrap_or(0),
original.get(p).copied().unwrap_or(p),
)
});
}
groups
}
/// Places the tracks from `added` on (just appended to the queue) at random
/// positions after the first `fixed`. Under album shuffle each added album
/// goes in as one block, and only between albums, never inside one.
pub fn insert(rng: &mut Rng, mode: Mode, songs: &[Song], original: &[usize], fixed: usize, added: usize) -> Vec<usize> {
let added = added.min(songs.len());
let fixed = fixed.min(added);
let mut tail: Vec<usize> = (fixed..added).collect();
if mode == Mode::Albums {
let mut blocks: Vec<Vec<usize>> = Vec::new();
for pos in tail {
let key = album_key(&songs[pos], pos);
match blocks.last_mut() {
Some(b) if album_key(&songs[b[0]], b[0]) == key => b.push(pos),
_ => blocks.push(vec![pos]),
}
}
// The rest of the album playing now still plays first.
let lo = match (fixed.checked_sub(1), blocks.first()) {
(Some(last), Some(b)) if album_key(&songs[last], last) == album_key(&songs[b[0]], b[0]) => 1,
_ => 0,
};
for (_, g) in album_groups(songs, original, added..songs.len()) {
let at = rng.usize(lo..=blocks.len());
blocks.insert(at, g);
}
tail = blocks.concat();
} else {
for pos in added..songs.len() {
let at = rng.usize(..=tail.len());
tail.insert(at, pos);
}
}
(0..fixed).chain(tail).collect()
}
/// Back to the original order, given each track's original position. A
/// `pinned` track (handed to playbin already) is moved to play right after
/// `playing`, so the track that plays next is the one the player expects.
pub fn unshuffle(original: &[usize], playing: Option<usize>, pinned: Option<usize>) -> Vec<usize> {
let mut perm: Vec<usize> = (0..original.len()).collect();
perm.sort_by_key(|&p| original[p]);
if let (Some(playing), Some(pinned)) = (playing, pinned)
&& playing != pinned
&& let Some(from) = perm.iter().position(|&p| p == pinned)
{
perm.remove(from);
let at = perm.iter().position(|&p| p == playing).map_or(perm.len(), |i| i + 1);
perm.insert(at, pinned);
}
perm
}
/// `items` reordered by `perm`.
pub fn apply<T: Clone>(items: &[T], perm: &[usize]) -> Vec<T> {
perm.iter().map(|&p| items[p].clone()).collect()
}
#[cfg(test)]
mod tests {
use super::*;
fn song(id: &str, album: Option<&str>, track: u32) -> Song {
serde_json::from_value(serde_json::json!({
"id": id, "title": id, "album": album.map(|a| format!("Album {a}")),
"albumId": album, "artist": "A", "track": track,
}))
.unwrap()
}
fn is_permutation(perm: &[usize], len: usize) -> bool {
let mut sorted = perm.to_vec();
sorted.sort();
sorted == (0..len).collect::<Vec<_>>()
}
#[test]
fn tracks_keeps_the_fixed_head_and_plays_the_rest_once() {
let mut rng = Rng::with_seed(1);
for fixed in [0, 1, 3, 10, 12] {
let perm = tracks(&mut rng, 10, fixed);
assert!(is_permutation(&perm, 10));
let fixed = fixed.min(10);
assert_eq!(perm[..fixed], (0..fixed).collect::<Vec<_>>()[..]);
}
}
#[test]
fn tracks_actually_shuffles() {
let mut rng = Rng::with_seed(7);
let perm = tracks(&mut rng, 50, 1);
assert_ne!(perm, (0..50).collect::<Vec<_>>());
}
#[test]
fn albums_finish_the_playing_album_then_play_whole_albums_in_track_order() {
// Track shuffled already: b2, a1, b1 | a2, c1, b3, a3, c2.
let songs = vec![
song("b2", Some("b"), 2),
song("a1", Some("a"), 1),
song("b1", Some("b"), 1),
song("a2", Some("a"), 2),
song("c2", Some("c"), 2),
song("b3", Some("b"), 3),
song("a3", Some("a"), 3),
song("c1", Some("c"), 1),
];
let original: Vec<usize> = (0..songs.len()).collect();
for seed in 0..20 {
let mut rng = Rng::with_seed(seed);
let perm = albums(&mut rng, &songs, &original, Some(0), 3);
assert!(is_permutation(&perm, songs.len()));
let ids: Vec<&str> = perm.iter().map(|&p| songs[p].id.as_str()).collect();
assert_eq!(ids[..3], ["b2", "a1", "b1"]);
assert_eq!(ids[3], "b3", "the playing album goes on first");
let rest = &ids[4..];
assert!(
rest == ["a2", "a3", "c1", "c2"] || rest == ["c1", "c2", "a2", "a3"],
"seed {seed}: {rest:?}"
);
}
}
#[test]
fn albums_with_the_same_name_stay_apart_and_saved_songs_fall_back_to_the_name() {
let mut same_name = song("x1", Some("x"), 1);
same_name.album = Some("Album y".into());
let mut saved = song("y2", None, 2);
saved.album = Some("Album y".into());
let mut saved1 = song("y1", None, 1);
saved1.album = Some("Album y".into());
let songs = vec![song("p", Some("p"), 1), saved, same_name, saved1];
let original: Vec<usize> = (0..songs.len()).collect();
let mut rng = Rng::with_seed(3);
let perm = albums(&mut rng, &songs, &original, Some(0), 1);
let ids: Vec<&str> = perm.iter().map(|&p| songs[p].id.as_str()).collect();
let y = ids.iter().position(|&i| i == "y1").unwrap();
assert_eq!(ids[y + 1], "y2", "{ids:?}");
assert!(ids.contains(&"x1"));
}
#[test]
fn tracks_without_numbers_keep_their_original_order() {
let mut songs: Vec<Song> = ["a", "b", "c"].iter().map(|id| song(id, Some("al"), 0)).collect();
for s in &mut songs {
s.track = None;
}
// Played as c, a, b; originally a, b, c.
let songs = vec![songs[2].clone(), songs[0].clone(), songs[1].clone()];
let original = vec![2, 0, 1];
let mut rng = Rng::with_seed(0);
let perm = albums(&mut rng, &songs, &original, None, 0);
let ids: Vec<&str> = perm.iter().map(|&p| songs[p].id.as_str()).collect();
assert_eq!(ids, ["a", "b", "c"]);
}
#[test]
fn insert_scatters_added_tracks_after_the_fixed_head() {
let songs: Vec<Song> = (0..20).map(|i| song(&i.to_string(), None, 0)).collect();
let original: Vec<usize> = (0..20).collect();
let mut rng = Rng::with_seed(5);
let perm = insert(&mut rng, Mode::Tracks, &songs, &original, 2, 15);
assert!(is_permutation(&perm, 20));
assert_eq!(perm[..2], [0, 1]);
let old: Vec<usize> = perm.iter().copied().filter(|&p| p < 15).collect();
assert_eq!(old, (0..15).collect::<Vec<_>>(), "the queued tracks keep their order");
assert_ne!(perm[15..], [15, 16, 17, 18, 19], "added tracks are not all at the end");
}
#[test]
fn insert_under_album_shuffle_adds_whole_albums_between_albums() {
let songs = vec![
song("p1", Some("p"), 1),
song("q1", Some("q"), 1),
song("q2", Some("q"), 2),
song("r1", Some("r"), 1),
song("r2", Some("r"), 2),
song("n2", Some("n"), 2),
song("n1", Some("n"), 1),
];
let original: Vec<usize> = (0..songs.len()).collect();
for seed in 0..20 {
let mut rng = Rng::with_seed(seed);
let perm = insert(&mut rng, Mode::Albums, &songs, &original, 1, 5);
let ids: Vec<&str> = perm.iter().map(|&p| songs[p].id.as_str()).collect();
let n = ids.iter().position(|&i| i == "n1").unwrap();
assert_eq!(ids[n + 1], "n2", "seed {seed}: {ids:?}");
assert!(
n >= 1 && ids[n - 1] != "q1" && ids[n - 1] != "r1",
"seed {seed}: {ids:?}"
);
}
}
#[test]
fn insert_under_album_shuffle_leaves_the_playing_album_first() {
let songs = vec![
song("p1", Some("p"), 1),
song("p2", Some("p"), 2),
song("q1", Some("q"), 1),
song("n1", Some("n"), 1),
];
let original: Vec<usize> = (0..songs.len()).collect();
for seed in 0..20 {
let mut rng = Rng::with_seed(seed);
let perm = insert(&mut rng, Mode::Albums, &songs, &original, 1, 3);
assert_eq!(perm[1], 1, "seed {seed}: {perm:?}");
}
}
#[test]
fn unshuffle_restores_the_original_order() {
let original = vec![3, 0, 4, 1, 2];
let perm = unshuffle(&original, Some(0), None);
assert_eq!(apply(&original, &perm), [0, 1, 2, 3, 4]);
}
#[test]
fn unshuffle_plays_the_pinned_track_next() {
// Playing original 3, playbin already has original 0.
let original = vec![1, 3, 0, 4, 2];
let perm = unshuffle(&original, Some(1), Some(2));
assert_eq!(apply(&original, &perm), [1, 2, 3, 0, 4]);
}
#[test]
fn modes_cycle_off_tracks_albums() {
assert_eq!(Mode::Off.next(), Mode::Tracks);
assert_eq!(Mode::Tracks.next(), Mode::Albums);
assert_eq!(Mode::Albums.next(), Mode::Off);
}
}
+102 -2
View File
@@ -4,8 +4,8 @@ use std::hash::{BuildHasher, RandomState};
use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::{Context, Result, anyhow, bail};
use serde::Deserialize;
use serde::de::{DeserializeOwned, Deserializer};
use serde::{Deserialize, Serialize};
const API_VERSION: &str = "1.16.1";
const CLIENT_NAME: &str = "remus";
@@ -212,6 +212,28 @@ impl Client {
Ok(r.artist)
}
/// Every song on the artist's albums, album by album. A few albums are
/// fetched at a time, so an artist with dozens does not flood the server.
pub async fn artist_songs(&self, id: &str) -> Result<Vec<Song>> {
let albums = self.artist(id).await?.album;
let limit = std::sync::Arc::new(tokio::sync::Semaphore::new(4));
let tasks: Vec<_> = albums
.into_iter()
.map(|a| {
let (client, limit) = (self.clone(), limit.clone());
tokio::spawn(async move {
let _permit = limit.acquire_owned().await?;
anyhow::Ok(client.album(&a.id).await?.song)
})
})
.collect();
let mut songs = Vec::new();
for t in tasks {
songs.extend(t.await??);
}
Ok(songs)
}
pub async fn album(&self, id: &str) -> Result<AlbumDetail> {
#[derive(Deserialize)]
struct R {
@@ -265,6 +287,23 @@ impl Client {
Ok(r.result)
}
/// Up to `size` random songs from the whole library. Servers cap `size`
/// at 500.
pub async fn random_songs(&self, size: u32) -> Result<Vec<Song>> {
#[derive(Deserialize)]
struct R {
#[serde(rename = "randomSongs", default)]
list: Songs,
}
#[derive(Deserialize, Default)]
struct Songs {
#[serde(default)]
song: Vec<Song>,
}
let r: R = self.call("getRandomSongs", &[("size", size.to_string())]).await?;
Ok(r.list.song)
}
pub async fn scrobble(&self, id: &str, submission: bool) -> Result<()> {
let _: serde_json::Value = self
.call("scrobble", &[("id", id.into()), ("submission", submission.to_string())])
@@ -415,7 +454,7 @@ pub struct AlbumDetail {
pub song: Vec<Song>,
}
#[derive(Debug, Clone, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Song {
#[serde(deserialize_with = "de_id")]
@@ -426,6 +465,9 @@ pub struct Song {
pub artist: Option<String>,
#[serde(default)]
pub album: Option<String>,
/// None in queues saved before it was kept, and from servers that leave it out.
#[serde(default, deserialize_with = "de_opt_id")]
pub album_id: Option<String>,
#[serde(default, deserialize_with = "de_opt_id")]
pub cover_art: Option<String>,
#[serde(default)]
@@ -489,6 +531,56 @@ mod tests {
let a: Album = serde_json::from_str(r#"{"id": 42, "name": "X", "coverArt": 7}"#).unwrap();
assert_eq!(a.id, "42");
assert_eq!(a.cover_art.as_deref(), Some("7"));
let s: Song = serde_json::from_str(r#"{"id": 1, "albumId": 42}"#).unwrap();
assert_eq!(s.album_id.as_deref(), Some("42"));
let s: Song = serde_json::from_str(r#"{"id": 1}"#).unwrap();
assert_eq!(s.album_id, None);
}
/// A loopback HTTP server that answers every request with `body` and
/// sends each request line back.
fn fake_server(body: &'static str) -> (String, std::sync::mpsc::Receiver<String>) {
use std::io::{BufRead, BufReader, Write};
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
for stream in listener.incoming() {
let Ok(mut stream) = stream else { continue };
let mut line = String::new();
let _ = BufReader::new(stream.try_clone().unwrap()).read_line(&mut line);
let _ = tx.send(line);
let _ = write!(
stream,
"HTTP/1.1 200 OK\r\ncontent-type: application/json\r\ncontent-length: {}\r\nconnection: close\r\n\r\n{body}",
body.len()
);
}
});
(format!("http://{addr}"), rx)
}
#[tokio::test]
async fn random_songs_asks_for_the_size_and_reads_the_songs() {
let (base, requests) = fake_server(
r#"{"subsonic-response":{"status":"ok","randomSongs":{"song":[
{"id":"s1","title":"One","albumId":"al-1"},{"id":"s2","title":"Two"}]}}}"#,
);
let c = Client::new(&base, "u", Auth::Password("sesame".into()));
let songs = c.random_songs(50).await.unwrap();
let ids: Vec<_> = songs.iter().map(|s| s.id.as_str()).collect();
assert_eq!(ids, ["s1", "s2"]);
assert_eq!(songs[0].album_id.as_deref(), Some("al-1"));
let line = requests.recv().unwrap();
assert!(line.contains("/rest/getRandomSongs?"), "{line}");
assert!(line.contains("size=50"), "{line}");
}
#[tokio::test]
async fn random_songs_from_an_empty_library_is_empty() {
let (base, _) = fake_server(r#"{"subsonic-response":{"status":"ok","randomSongs":{}}}"#);
let c = Client::new(&base, "u", Auth::Password("sesame".into()));
assert!(c.random_songs(50).await.unwrap().is_empty());
}
/// Exercises every endpoint against a real server:
@@ -514,6 +606,7 @@ mod tests {
assert!(!albums.is_empty(), "no albums");
let album = c.album(&albums[0].id).await.unwrap();
assert!(!album.song.is_empty(), "album has no songs");
assert_eq!(album.song[0].album_id.as_deref(), Some(albums[0].id.as_str()));
println!(
"album: {} by {:?}, {} songs",
album.name,
@@ -530,6 +623,9 @@ mod tests {
assert!(!artists.is_empty(), "no artists");
let artist = c.artist(&artists[0].id).await.unwrap();
println!("artist: {} with {} albums", artist.name, artist.album.len());
let songs = c.artist_songs(&artists[0].id).await.unwrap();
assert!(!songs.is_empty(), "artist has no songs");
println!("artist songs: {}", songs.len());
let playlists = c.playlists().await.unwrap();
if let Some(p) = playlists.first() {
@@ -537,6 +633,10 @@ mod tests {
println!("playlist: {} with {} entries", p.name, p.entry.len());
}
let random = c.random_songs(20).await.unwrap();
assert!(!random.is_empty(), "no random songs");
println!("random: {} songs", random.len());
let found = c.search(&album.name).await.unwrap();
assert!(!found.album.is_empty(), "search found nothing for {}", album.name);
+641 -93
View File
@@ -9,6 +9,7 @@ export enum Action {
none, up, down, left, right, page-up, page-down, activate, back,
play-pause, next, prev, queue, section-next, section-prev,
now-playing, search, seek-forward, seek-back, toggle-fullscreen, quit,
volume-up, volume-down, toggle-mute, cycle-shuffle, shuffle, hold-activate,
}
export enum Screen { login, browse, now-playing }
@@ -27,6 +28,11 @@ export struct Item {
round: bool,
show-art: bool,
playing: bool,
// A setting with a range: draws `level` (0 to 1) as a slider before `detail`.
slider: bool,
level: float,
// Button or key icons after `detail`, on the Controls page.
icons: [image],
}
export struct Header {
@@ -44,6 +50,9 @@ export struct Header {
export struct Hint { icons: [image], label: string }
// A saved server on the login screen: its label, and "Logged out" or nothing.
export struct KnownServer { label: string, note: string }
export global Theme {
in-out property <float> s: 1.0;
// The brand palette: warm darks and cream text, from the logo's maroon
@@ -209,8 +218,10 @@ component Row inherits Rectangle {
round: root.item.round;
}
}
// As wide as the art, so a row with a cover and a row with a number
// line up, as on an album where some tracks have their own cover.
if !root.item.show-art: Text {
width: 34px * Theme.s;
width: 46px * Theme.s;
text: root.item.playing ? "▶" : root.item.number;
font-size: 15px * Theme.s;
color: root.item.playing ? Theme.highlight : Theme.faint;
@@ -237,12 +248,53 @@ component Row inherits Rectangle {
}
}
if root.item.slider: VerticalLayout {
alignment: center;
Rectangle {
width: 180px * Theme.s;
height: 6px * Theme.s;
border-radius: 3px * Theme.s;
background: Theme.line;
Rectangle {
x: 0;
width: parent.width * root.item.level;
border-radius: 3px * Theme.s;
background: root.selected && root.active ? Theme.highlight : Theme.muted;
animate width { duration: 120ms; easing: ease-out; }
}
Rectangle {
x: parent.width * root.item.level - self.width / 2;
width: 16px * Theme.s;
height: 16px * Theme.s;
border-radius: 8px * Theme.s;
background: root.selected && root.active ? Theme.text : Theme.muted;
animate x { duration: 120ms; easing: ease-out; }
}
}
}
Text {
// Fixed for a slider, so the bar does not shift as the number grows.
min-width: root.item.slider ? 44px * Theme.s : 0;
text: root.item.detail;
font-size: 15px * Theme.s;
color: Theme.muted;
horizontal-alignment: right;
vertical-alignment: center;
}
if root.item.icons.length > 0: HorizontalLayout {
spacing: 4px * Theme.s;
for icon in root.item.icons: VerticalLayout {
alignment: center;
Image {
source: icon;
height: 34px * Theme.s;
// Keys such as Space are wider than a button.
width: self.height * icon.width / max(1, icon.height);
}
}
}
}
TouchArea {
@@ -473,6 +525,237 @@ component SearchBox inherits Rectangle {
}
}
// Play triangle or pause bars, drawn as vectors so no font fallback can turn
// them into emoji or give the two different weights.
component PlayState {
in property <bool> paused;
in property <color> tint: Theme.highlight;
in property <length> size: 14px * Theme.s;
width: root.size;
height: root.size;
if !root.paused: Path {
width: root.size;
height: root.size;
viewbox-width: 12;
viewbox-height: 12;
commands: "M 1.5 0.5 L 11.5 6 L 1.5 11.5 Z";
fill: root.tint;
}
if root.paused: Rectangle {
x: root.size * 0.12;
width: root.size * 0.28;
height: root.size;
border-radius: root.size * 0.06;
background: root.tint;
}
if root.paused: Rectangle {
x: root.size * 0.60;
width: root.size * 0.28;
height: root.size;
border-radius: root.size * 0.06;
background: root.tint;
}
}
// A speaker with sound waves, or with a cross when muted.
component Speaker {
in property <bool> muted;
in property <color> tint: Theme.text;
in property <length> size: 16px * Theme.s;
width: root.size;
height: root.size;
Path {
width: root.size;
height: root.size;
viewbox-width: 16;
viewbox-height: 16;
commands: "M 1 5.5 L 4.5 5.5 L 8.5 2 L 8.5 14 L 4.5 10.5 L 1 10.5 Z";
fill: root.tint;
}
Path {
width: root.size;
height: root.size;
viewbox-width: 16;
viewbox-height: 16;
commands: root.muted
? "M 10.5 5.5 L 15 10 M 15 5.5 L 10.5 10"
: "M 10.5 5.5 A 3.2 3.2 0 0 1 10.5 10.5 M 12.5 3.5 A 6 6 0 0 1 12.5 12.5";
stroke: root.tint;
stroke-width: 1.6px * root.size / 16px;
}
}
// A quiet speaker, bar and number for the current volume.
component VolumeLevel inherits HorizontalLayout {
in property <int> level;
in property <bool> muted;
in property <length> font-size: 13px * Theme.s;
// The speaker gets a box as wide as the number, so the bar is the middle
// of the whole and centring the row centres the bar.
in property <bool> balanced;
// Fixed, so the bar does not shift as the number changes, and wide enough
// for "Muted".
property <length> label-width: 4.2 * root.font-size;
spacing: 10px * Theme.s;
// Its own width only, so a stretching row does not hand it the slack.
horizontal-stretch: 0;
HorizontalLayout {
width: root.balanced ? root.label-width : 14px * Theme.s;
alignment: end;
Speaker {
muted: root.muted || root.level == 0;
tint: Theme.muted;
size: 14px * Theme.s;
y: (parent.height - self.height) / 2;
}
}
VerticalLayout {
alignment: center;
Rectangle {
width: 90px * Theme.s;
height: 4px * Theme.s;
border-radius: 2px * Theme.s;
background: Theme.raised;
Rectangle {
x: 0;
width: parent.width * (root.muted ? 0 : root.level / 100);
border-radius: 2px * Theme.s;
background: Theme.muted;
}
}
}
Text {
width: root.label-width;
text: root.muted ? "Muted" : root.level;
font-size: root.font-size;
color: Theme.muted;
vertical-alignment: center;
}
}
// The level after a volume change, faded out again by the app after a moment.
// Asks before doing something that cannot be undone from where it is asked.
// The choices sit in a row; the app moves the selection and starts with the
// first, which is Cancel.
component ConfirmDialog inherits Rectangle {
in property <string> title;
in property <string> message;
in property <[string]> choices;
in property <int> selected;
callback clicked(int);
background: #00000099;
// Keeps clicks from reaching the page behind.
TouchArea { }
Rectangle {
width: min(620px * Theme.s, parent.width - 40px * Theme.s);
height: col.preferred-height;
border-radius: 18px * Theme.s;
background: Theme.panel;
border-width: 1px * Theme.s;
border-color: Theme.line;
drop-shadow-blur: 30px * Theme.s;
drop-shadow-color: #00000080;
col := VerticalLayout {
padding: 34px * Theme.s;
spacing: 18px * Theme.s;
Text {
text: root.title;
font-size: 24px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
wrap: word-wrap;
}
Text {
text: root.message;
font-size: 16px * Theme.s;
color: Theme.muted;
wrap: word-wrap;
}
HorizontalLayout {
spacing: 12px * Theme.s;
padding-top: 6px * Theme.s;
for label[i] in root.choices: Rectangle {
height: 50px * Theme.s;
border-radius: 12px * Theme.s;
background: i == root.selected ? Theme.accent : Theme.raised;
border-width: 2px * Theme.s;
border-color: i == root.selected ? Theme.focus : transparent;
Text {
text: label;
font-size: 18px * Theme.s;
font-weight: i == root.selected ? 700 : 500;
color: i == root.selected ? Theme.on-accent : Theme.text;
}
TouchArea {
clicked => { root.clicked(i); }
}
}
}
}
}
}
component VolumeOverlay inherits Rectangle {
in property <bool> shown;
in property <int> level;
in property <bool> muted;
width: 300px * Theme.s;
height: 56px * Theme.s;
border-radius: 28px * Theme.s;
background: Theme.raised;
border-width: 1px * Theme.s;
border-color: Theme.line;
drop-shadow-blur: 20px * Theme.s;
drop-shadow-color: #00000080;
opacity: root.shown ? 1 : 0;
animate opacity { duration: 180ms; }
HorizontalLayout {
padding-left: 22px * Theme.s;
padding-right: 22px * Theme.s;
spacing: 14px * Theme.s;
VerticalLayout {
alignment: center;
Speaker {
muted: root.muted || root.level == 0;
size: 22px * Theme.s;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Rectangle {
height: 6px * Theme.s;
border-radius: 3px * Theme.s;
background: Theme.line;
Rectangle {
x: 0;
width: parent.width * (root.muted ? 0 : root.level / 100);
border-radius: 3px * Theme.s;
background: Theme.highlight;
animate width { duration: 100ms; easing: ease-out; }
}
}
}
Text {
min-width: 48px * Theme.s;
text: root.muted ? "Muted" : root.level;
font-size: 16px * Theme.s;
color: Theme.text;
horizontal-alignment: right;
vertical-alignment: center;
}
}
}
component NowBar inherits Rectangle {
in property <bool> has-track;
in property <string> title;
@@ -484,6 +767,8 @@ component NowBar inherits Rectangle {
in property <float> progress;
in property <string> time;
in property <bool> paused;
in property <int> volume;
in property <bool> muted;
background: Theme.panel;
@@ -543,11 +828,18 @@ component NowBar inherits Rectangle {
color: Theme.muted;
vertical-alignment: center;
}
if root.has-track: Text {
text: root.paused ? "❚❚" : "▶";
font-size: 18px * Theme.s;
color: Theme.highlight;
vertical-alignment: center;
if root.has-track: VerticalLayout {
alignment: center;
PlayState {
paused: root.paused;
size: 15px * Theme.s;
}
}
if root.has-track: Rectangle { width: 6px * Theme.s; }
if root.has-track: VolumeLevel {
level: root.volume;
muted: root.muted;
font-size: 15px * Theme.s;
}
}
}
@@ -600,6 +892,8 @@ component Field inherits VerticalLayout {
in property <string> label;
in-out property <string> text;
in property <bool> password;
// A password field shows its text while this is set, toggled by the eye.
in-out property <bool> shown;
in property <bool> highlighted;
callback accepted;
public function focus-input() {
@@ -620,16 +914,55 @@ component Field inherits VerticalLayout {
border-color: input.has-focus || root.highlighted ? Theme.focus : Theme.line;
input := TextInput {
x: 16px * Theme.s;
width: parent.width - 32px * Theme.s;
// Leaves room for the eye on a password field.
width: parent.width - (root.password ? 64px : 32px) * Theme.s;
height: parent.height;
text <=> root.text;
font-size: 19px * Theme.s;
color: Theme.text;
vertical-alignment: center;
single-line: true;
input-type: root.password ? InputType.password : InputType.text;
input-type: root.password && !root.shown ? InputType.password : InputType.text;
accepted => { root.accepted(); }
}
if root.password: Rectangle {
x: parent.width - self.width - 8px * Theme.s;
width: 40px * Theme.s;
height: parent.height;
// An eye to show the password, struck through to hide it again.
Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 1.5 12 C 4.5 6.5 8 4.5 12 4.5 C 16 4.5 19.5 6.5 22.5 12 C 19.5 17.5 16 19.5 12 19.5 C 8 19.5 4.5 17.5 1.5 12 Z";
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 1.6px * Theme.s;
}
Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 12 8.5 A 3.5 3.5 0 1 1 11.99 8.5 Z";
fill: eye-area.has-hover ? Theme.text : Theme.muted;
}
if root.shown: Path {
width: 22px * Theme.s;
height: 22px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 3 21 L 21 3";
stroke: eye-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 1.8px * Theme.s;
}
eye-area := TouchArea {
clicked => {
root.shown = !root.shown;
input.focus();
}
}
}
}
}
@@ -637,11 +970,19 @@ component LoginView inherits Rectangle {
in-out property <string> server;
in-out property <string> username;
in-out property <string> password;
in-out property <bool> password-shown;
in property <int> focus-index;
in property <string> error;
in property <bool> busy;
// Adding a server from inside the app: the bottom button goes back.
in property <bool> can-cancel;
// Saved servers above the form, and which one has focus, -1 for none.
in property <[KnownServer]> known;
in property <int> known-selected: -1;
callback submit;
callback exit;
callback field-clicked(int);
callback known-clicked(int);
public function focus-field(i: int) {
if (i == 0) {
f0.focus-input();
@@ -654,74 +995,165 @@ component LoginView inherits Rectangle {
background: @radial-gradient(circle, Theme.login-glow 0%, Theme.bg 70%);
Rectangle {
width: min(560px * Theme.s, parent.width - 40px * Theme.s);
height: col.preferred-height;
border-radius: 18px * Theme.s;
background: Theme.panel;
// Saved servers in a card of their own beside the form, so the form is
// as tall as without them and still fits an 800 px high screen.
HorizontalLayout {
alignment: center;
spacing: 24px * Theme.s;
padding: 20px * Theme.s;
col := VerticalLayout {
padding: 40px * Theme.s;
spacing: 20px * Theme.s;
HorizontalLayout {
alignment: start;
Image {
source: @image-url("../branding/svg/remus-logo.svg");
height: 68px * Theme.s;
// The lockup's aspect ratio, so the image box hugs the logo.
width: self.height * 2.93;
}
}
Text {
text: "Connect to your Subsonic server";
font-size: 17px * Theme.s;
color: Theme.muted;
}
f0 := Field {
label: "Server address";
text <=> root.server;
highlighted: root.focus-index == 0;
accepted => { root.field-clicked(1); }
}
f1 := Field {
label: "Username";
text <=> root.username;
highlighted: root.focus-index == 1;
accepted => { root.field-clicked(2); }
}
f2 := Field {
label: "Password";
text <=> root.password;
password: true;
highlighted: root.focus-index == 2;
accepted => { root.submit(); }
}
if root.known.length > 0: VerticalLayout {
alignment: center;
Rectangle {
height: 54px * Theme.s;
border-radius: 12px * Theme.s;
background: root.focus-index == 3 ? Theme.accent : Theme.raised;
Text {
text: root.busy ? "Connecting…" : "Connect";
font-size: 19px * Theme.s;
font-weight: 700;
color: root.focus-index == 3 ? Theme.on-accent : Theme.text;
}
TouchArea {
clicked => { root.submit(); }
preferred-width: 400px * Theme.s;
min-width: 240px * Theme.s;
border-radius: 18px * Theme.s;
background: Theme.panel;
VerticalLayout {
padding: 28px * Theme.s;
spacing: 10px * Theme.s;
Text {
text: "Saved servers";
font-size: 22px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
}
Text {
text: "Pick one to fill in its address and username.";
font-size: 14px * Theme.s;
color: Theme.muted;
wrap: word-wrap;
}
for k[i] in root.known: Rectangle {
height: 58px * Theme.s;
border-radius: 10px * Theme.s;
background: i == root.known-selected ? Theme.raised : transparent;
border-width: 2px * Theme.s;
border-color: i == root.known-selected ? Theme.focus : Theme.line;
VerticalLayout {
padding-left: 16px * Theme.s;
padding-right: 16px * Theme.s;
alignment: center;
Text {
text: k.label;
font-size: 17px * Theme.s;
color: Theme.text;
overflow: elide;
}
if k.note != "": Text {
text: k.note;
font-size: 13px * Theme.s;
color: Theme.faint;
}
}
TouchArea {
clicked => { root.known-clicked(i); }
}
}
}
}
if root.error != "": Text {
text: root.error;
font-size: 15px * Theme.s;
color: Theme.error;
wrap: word-wrap;
}
Text {
text: "On a Steam Deck, press Steam + X to bring up the keyboard.";
font-size: 13px * Theme.s;
color: Theme.faint;
wrap: word-wrap;
}
VerticalLayout {
alignment: center;
Rectangle {
preferred-width: 560px * Theme.s;
min-width: 320px * Theme.s;
height: col.preferred-height;
border-radius: 18px * Theme.s;
background: Theme.panel;
col := VerticalLayout {
padding: 40px * Theme.s;
spacing: 20px * Theme.s;
HorizontalLayout {
alignment: center;
Image {
source: @image-url("../branding/svg/remus-logo.svg");
height: 68px * Theme.s;
// The lockup's aspect ratio, so the image box hugs the logo.
width: self.height * 2.93;
}
}
Text {
text: "Connect to your Subsonic server";
font-size: 17px * Theme.s;
color: Theme.muted;
}
f0 := Field {
label: "Server address";
text <=> root.server;
highlighted: root.focus-index == 0;
accepted => { root.field-clicked(1); }
}
f1 := Field {
label: "Username";
text <=> root.username;
highlighted: root.focus-index == 1;
accepted => { root.field-clicked(2); }
}
f2 := Field {
label: "Password";
text <=> root.password;
password: true;
shown <=> root.password-shown;
highlighted: root.focus-index == 2;
accepted => { root.submit(); }
}
Rectangle {
height: 54px * Theme.s;
border-radius: 12px * Theme.s;
background: root.focus-index == 3 ? Theme.accent : Theme.raised;
Text {
text: root.busy ? "Connecting…" : "Connect";
font-size: 19px * Theme.s;
font-weight: 700;
color: root.focus-index == 3 ? Theme.on-accent : Theme.text;
}
TouchArea {
clicked => { root.submit(); }
}
}
if root.error != "": Text {
text: root.error;
font-size: 15px * Theme.s;
color: Theme.error;
wrap: word-wrap;
}
Text {
text: "On a Steam Deck, press Steam + X to bring up the keyboard.";
font-size: 13px * Theme.s;
color: Theme.faint;
wrap: word-wrap;
}
}
// Exit, or Cancel when adding a server from inside the app. A
// corner button rather than a row, to keep the card short.
Rectangle {
x: parent.width - self.width - 14px * Theme.s;
y: 14px * Theme.s;
width: 44px * Theme.s;
height: 44px * Theme.s;
border-radius: self.width / 2;
background: root.focus-index == -1 || x-area.has-hover ? Theme.raised : transparent;
border-width: 2px * Theme.s;
border-color: root.focus-index == -1 ? Theme.focus : transparent;
Path {
width: 18px * Theme.s;
height: 18px * Theme.s;
viewbox-width: 24;
viewbox-height: 24;
commands: "M 4 4 L 20 20 M 20 4 L 4 20";
stroke: root.focus-index == -1 || x-area.has-hover ? Theme.text : Theme.muted;
stroke-width: 2px * Theme.s;
}
x-area := TouchArea {
clicked => { root.exit(); }
}
}
}
}
}
@@ -740,24 +1172,36 @@ component NowPlayingView inherits Rectangle {
in property <string> duration;
in property <bool> paused;
in property <bool> has-track;
// From the cover backdrop setting: the blown-up cover's opacity and the
// alpha of the background drawn over it, at the left and right edges.
in property <int> volume: 100;
in property <bool> muted;
in property <float> backdrop-opacity: 0.16;
in property <float> backdrop-left: 0.67;
in property <float> backdrop-right: 0.95;
// True while the cover turns away; the app swaps the cover at edge-on and
// sets it back to false to turn the new one in.
in property <bool> flip-out;
in property <[Item]> queue;
in property <int> queue-count;
in property <int> queue-selected;
// How the queue is shuffled, empty when it plays in order.
in property <string> shuffle;
callback queue-clicked(int);
callback queue-wheel(int);
// From the scale, not our own size: a layout child sized from its parent loops.
out property <length> art-size: 440px * Theme.s;
// Blown-up cover as a dim backdrop.
if root.has-cover: Image {
if root.has-cover && root.backdrop-opacity > 0: Image {
width: parent.width;
height: parent.height;
source: root.cover;
image-fit: ImageFit.cover;
opacity: 0.16;
opacity: root.backdrop-opacity;
}
Rectangle {
background: @linear-gradient(90deg, Theme.bg.with-alpha(0.67), Theme.bg.with-alpha(0.95));
background: @linear-gradient(90deg, Theme.bg.with-alpha(root.backdrop-left), Theme.bg.with-alpha(root.backdrop-right));
}
HorizontalLayout {
@@ -770,9 +1214,11 @@ component NowPlayingView inherits Rectangle {
spacing: 10px * Theme.s;
width: root.art-size;
Art {
art := Art {
width: root.art-size;
height: root.art-size;
// Set here so the turned state below has a value to return to.
transform-scale-x: 100%;
source: root.cover;
has-image: root.has-cover;
tint: root.tint;
@@ -814,36 +1260,61 @@ component NowPlayingView inherits Rectangle {
background: Theme.highlight;
}
}
HorizontalLayout {
Text {
// Placed by hand: the icon on the bar's midpoint whatever the
// widths of the two times, which a layout would share out.
Rectangle {
height: position-text.preferred-height;
position-text := Text {
x: 0;
width: self.preferred-width;
text: root.position;
font-size: 14px * Theme.s;
color: Theme.muted;
}
Text {
horizontal-stretch: 1;
text: root.has-track ? (root.paused ? "Paused" : "Playing") : "";
font-size: 14px * Theme.s;
color: Theme.highlight;
horizontal-alignment: center;
}
Text {
x: parent.width - self.width;
width: self.preferred-width;
text: root.duration;
font-size: 14px * Theme.s;
color: Theme.muted;
}
if root.has-track: PlayState {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
paused: root.paused;
size: 11px * Theme.s;
}
}
HorizontalLayout {
alignment: center;
VolumeLevel {
level: root.volume;
muted: root.muted;
balanced: true;
}
}
}
VerticalLayout {
spacing: 14px * Theme.s;
horizontal-stretch: 1;
Text {
text: "Queue";
font-size: 28px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
HorizontalLayout {
spacing: 16px * Theme.s;
Text {
text: "Queue";
font-size: 28px * Theme.s;
font-family: Theme.serif;
font-weight: 600;
color: Theme.text;
}
Text {
horizontal-stretch: 1;
text: root.shuffle;
font-size: 16px * Theme.s;
color: Theme.muted;
vertical-alignment: center;
overflow: elide;
}
}
ItemView {
vertical-stretch: 1;
@@ -857,6 +1328,20 @@ component NowPlayingView inherits Rectangle {
}
}
}
// A flip around the vertical axis, faked by squashing the width: Slint has
// no perspective. The turn back overshoots a little and settles.
states [
turned when root.flip-out: {
art.transform-scale-x: 0%;
in {
animate art.transform-scale-x { duration: 170ms; easing: ease-in; }
}
out {
animate art.transform-scale-x { duration: 380ms; easing: cubic-bezier(0.34, 1.5, 0.64, 1); }
}
}
]
}
export component AppWindow inherits Window {
@@ -877,6 +1362,8 @@ export component AppWindow inherits Window {
callback search-accepted(string);
callback login-submit();
callback login-field-clicked(int);
callback login-known-clicked(int);
callback confirm-clicked(int);
callback layout-changed();
in property <Screen> screen: Screen.login;
@@ -889,6 +1376,10 @@ export component AppWindow inherits Window {
in property <int> login-focus;
in property <string> login-error;
in property <bool> login-busy;
in property <bool> login-can-cancel;
in-out property <bool> login-password-shown;
in property <[KnownServer]> login-known;
in property <int> login-known-selected: -1;
// Browse
in property <[string]> sections;
@@ -920,6 +1411,11 @@ export component AppWindow inherits Window {
in property <string> np-position;
in property <string> np-duration;
in property <bool> np-paused;
in property <string> np-shuffle;
in property <bool> np-flip-out;
in property <float> np-backdrop-opacity: 0.16;
in property <float> np-backdrop-left: 0.67;
in property <float> np-backdrop-right: 0.95;
in property <[Item]> queue-items;
in property <int> queue-count;
in property <int> queue-selected;
@@ -927,7 +1423,19 @@ export component AppWindow inherits Window {
in property <[Hint]> hints;
in property <string> toast;
// The volume overlay, shown briefly after any volume change.
in property <bool> volume-shown;
in property <int> volume;
in property <bool> muted;
in property <string> version;
in property <bool> show-hint-bar: true;
// The confirmation prompt, over everything else while shown.
in property <bool> confirm-shown;
in property <string> confirm-title;
in property <string> confirm-message;
in property <[string]> confirm-choices;
in property <int> confirm-selected;
public function focus-main() {
fs.focus();
@@ -936,7 +1444,8 @@ export component AppWindow inherits Window {
search.focus-input();
}
public function focus-login(i: int) {
if (i >= 3) {
// Below 0 is the X or a saved server, 3 is Connect: keys go to the scope.
if (i >= 3 || i < 0) {
fs.focus();
} else {
login.focus-field(i);
@@ -980,6 +1489,12 @@ export component AppWindow inherits Window {
if (e.text == "f") { root.action(Action.now-playing); return accept; }
if (e.text == ",") { root.action(Action.seek-back); return accept; }
if (e.text == ".") { root.action(Action.seek-forward); return accept; }
// = is + without shift on most layouts.
if (e.text == "+" || e.text == "=") { root.action(Action.volume-up); return accept; }
if (e.text == "-") { root.action(Action.volume-down); return accept; }
if (e.text == "m") { root.action(Action.toggle-mute); return accept; }
if (e.text == "s") { root.action(Action.cycle-shuffle); return accept; }
if (e.text == "S") { root.action(Action.shuffle); return accept; }
reject
}
@@ -995,11 +1510,17 @@ export component AppWindow inherits Window {
server <=> root.login-server;
username <=> root.login-username;
password <=> root.login-password;
password-shown <=> root.login-password-shown;
focus-index: root.login-focus;
error: root.login-error;
busy: root.login-busy;
submit => { root.login-submit(); }
can-cancel: root.login-can-cancel;
exit => { root.action(root.login-can-cancel ? Action.back : Action.quit); }
field-clicked(i) => { root.login-field-clicked(i); }
known: root.login-known;
known-selected: root.login-known-selected;
known-clicked(i) => { root.login-known-clicked(i); }
}
Rectangle {
@@ -1080,9 +1601,16 @@ export component AppWindow inherits Window {
duration: root.np-duration;
paused: root.np-paused;
has-track: root.np-has-track;
flip-out: root.np-flip-out;
volume: root.volume;
muted: root.muted;
backdrop-opacity: root.np-backdrop-opacity;
backdrop-left: root.np-backdrop-left;
backdrop-right: root.np-backdrop-right;
queue: root.queue-items;
queue-count: root.queue-count;
queue-selected: root.queue-selected;
shuffle: root.np-shuffle;
queue-clicked(i) => { root.queue-clicked(i); }
queue-wheel(d) => { root.queue-wheel(d); }
}
@@ -1104,6 +1632,22 @@ export component AppWindow inherits Window {
color: Theme.text;
}
}
if root.confirm-shown: ConfirmDialog {
title: root.confirm-title;
message: root.confirm-message;
choices: root.confirm-choices;
selected: root.confirm-selected;
clicked(i) => { root.confirm-clicked(i); }
}
VolumeOverlay {
x: (parent.width - self.width) / 2;
y: parent.height - self.height - 32px * Theme.s;
shown: root.volume-shown;
level: root.volume;
muted: root.muted;
}
}
if root.screen == Screen.browse: NowBar {
@@ -1118,9 +1662,13 @@ export component AppWindow inherits Window {
progress: root.np-progress;
time: root.np-position + " / " + root.np-duration;
paused: root.np-paused;
volume: root.volume;
muted: root.muted;
}
HintBar {
// Optional, except on the login screen, where the controls are
// not known yet and Settings cannot be reached.
if root.show-hint-bar || root.screen == Screen.login: HintBar {
height: 46px * Theme.s;
hints: root.hints;
version: root.version;
+6
View File
@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M22 42 L26 42 26 32 31 42 33 42 38 32 38 42 42 42 42 22 38 22 32 34 26 22 22 22 22 42 M16 8 L48 8 Q56 8 56 16 L56 48 Q56 56 48 56 L16 56 Q8 56 8 48 L8 16 Q8 8 16 8"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 345 B

+6
View File
@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M16 8 L48 8 Q56 8 56 16 L56 48 Q56 56 48 56 L16 56 Q8 56 8 48 L8 16 Q8 8 16 8 M40 30 L24 30 24 34 40 34 40 30"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 291 B

+6
View File
@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M40 30 L34 30 34 24 30 24 30 30 24 30 24 34 30 34 30 40 34 40 34 34 40 34 40 30 M16 8 L48 8 Q56 8 56 16 L56 48 Q56 52.9 53 54.8 51.1 56 48 56 L16 56 Q12.9 56 11 54.8 8 52.9 8 48 L8 16 Q8 8 16 8"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 375 B

+9
View File
@@ -0,0 +1,9 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg">
<defs>
<mask id="letter">
<rect width="64" height="64" fill="#FFFFFF"/>
<path fill="none" stroke="#000000" stroke-width="4" stroke-linecap="square" d="M38 25.5 Q36.5 24 32 24 Q26 24 26 28 Q26 32 32 32 Q38 32 38 36 Q38 40 32 40 Q27.5 40 26 38.5"/>
</mask>
</defs>
<path stroke="none" fill="#FFFFFF" mask="url(#letter)" d="M16 8 L48 8 Q56 8 56 16 L56 48 Q56 56 48 56 L16 56 Q8 56 8 48 L8 16 Q8 8 16 8"/>
</svg>

After

Width:  |  Height:  |  Size: 499 B

+9
View File
@@ -0,0 +1,9 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg">
<defs>
<mask id="glyph">
<rect width="64" height="64" fill="#FFFFFF"/>
<path fill="none" stroke="#000000" stroke-width="3.5" stroke-linejoin="round" d="M32 21 L42 32 L36.5 32 L36.5 42 L27.5 42 L27.5 32 L22 32 Z"/>
</mask>
</defs>
<path stroke="none" fill="#FFFFFF" mask="url(#glyph)" d="M16 8 L48 8 Q56 8 56 16 L56 48 Q56 56 48 56 L16 56 Q8 56 8 48 L8 16 Q8 8 16 8"/>
</svg>

After

Width:  |  Height:  |  Size: 465 B

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 18.5 10.85 22.75 9.45 L26.15 12.95 Q21.25 14.05 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 23.45 42.5 32 42.5 40.55 42.5 46.55 37.7 L46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 42.75 14.05 37.9 12.95 L41.25 9.45 Q45.5 10.85 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.05 37 32 37 24.85 37 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q23.65 16.05 28.4 15.3 L28.7 15.6 Q30 17 32 17 33.85 17.05 35.3 15.65 L35.3 15.6 35.6 15.3 Q40.5 16.05 44.2 19 L44.15 19 M30.85 13.5 L24.45 6.85 Q24 6.35 24 5.65 24 4.95 24.45 4.5 24.9 4 25.6 4 L38.4 4 Q39.05 4 39.55 4.5 40 4.95 40 5.65 40 6.35 39.55 6.85 L33.15 13.5 Q32.65 14 32 14 31.3 14 30.85 13.5 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 17.8 11.4 21 10.1 L21 10.35 Q21 12.25 22.25 13.5 L22.75 14 Q19.85 15.15 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 L21.25 40.15 Q21 40.8 21 41.65 21 43.5 22.25 44.85 L22.3 44.95 28.7 51.6 Q30 53 32 53 33.85 53.05 35.3 51.65 L35.3 51.6 41.7 44.95 41.8 44.85 Q43 43.5 43 41.65 L42.8 40.15 46.55 37.7 46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 44.1 15.15 41.3 14 L41.7 13.6 Q43 12.35 43 10.35 L43 10.1 Q46.2 11.4 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.35 36.75 32.8 37 L31.2 37 Q24.55 36.75 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q24.7 15.2 31.2 15 L32.8 15 Q39.45 15.25 44.2 19 L44.15 19 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30.85 2.5 Q31.3 2 32 2 32.65 2 33.15 2.5 L39.55 9.15 Q40 9.65 40 10.35 40 11.05 39.55 11.5 39.05 12 38.4 12 L25.6 12 Q24.9 12 24.45 11.5 24 11.05 24 10.35 24 9.65 24.45 9.15 L30.85 2.5 M30.85 49.5 L24.45 42.85 Q24 42.35 24 41.65 L24.05 41.3 24.45 40.5 Q24.9 40 25.6 40 L38.4 40 Q39.05 40 39.55 40.5 L40 41.3 40 41.65 Q40 42.35 39.55 42.85 L33.15 49.5 Q32.65 50 32 50 31.3 50 30.85 49.5"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 18.5 10.85 22.75 9.45 L26.15 12.95 Q21.25 14.05 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 23.45 42.5 32 42.5 40.55 42.5 46.55 37.7 L46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 42.75 14.05 37.9 12.95 L41.25 9.45 Q45.5 10.85 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.05 37 32 37 24.85 37 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q23.65 16.05 28.4 15.3 L28.7 15.6 Q30 17 32 17 33.85 17.05 35.3 15.65 L35.3 15.6 35.6 15.3 Q40.5 16.05 44.2 19 L44.15 19 M30.85 13.5 L24.45 6.85 Q24 6.35 24 5.65 24 4.95 24.45 4.5 24.9 4 25.6 4 L38.4 4 Q39.05 4 39.55 4.5 40 4.95 40 5.65 40 6.35 39.55 6.85 L33.15 13.5 Q32.65 14 32 14 31.3 14 30.85 13.5 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 17.8 11.4 21 10.1 L21 10.35 Q21 12.25 22.25 13.5 L22.75 14 Q19.85 15.15 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 L21.25 40.15 Q21 40.8 21 41.65 21 43.5 22.25 44.85 L22.3 44.95 28.7 51.6 Q30 53 32 53 33.85 53.05 35.3 51.65 L35.3 51.6 41.7 44.95 41.8 44.85 Q43 43.5 43 41.65 L42.8 40.15 46.55 37.7 46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 44.1 15.15 41.3 14 L41.7 13.6 Q43 12.35 43 10.35 L43 10.1 Q46.2 11.4 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.35 36.75 32.8 37 L31.2 37 Q24.55 36.75 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q24.7 15.2 31.2 15 L32.8 15 Q39.45 15.25 44.2 19 L44.15 19 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30.85 2.5 Q31.3 2 32 2 32.65 2 33.15 2.5 L39.55 9.15 Q40 9.65 40 10.35 40 11.05 39.55 11.5 39.05 12 38.4 12 L25.6 12 Q24.9 12 24.45 11.5 24 11.05 24 10.35 24 9.65 24.45 9.15 L30.85 2.5 M30.85 49.5 L24.45 42.85 Q24 42.35 24 41.65 L24.05 41.3 24.45 40.5 Q24.9 40 25.6 40 L38.4 40 Q39.05 40 39.55 40.5 L40 41.3 40 41.65 Q40 42.35 39.55 42.85 L33.15 49.5 Q32.65 50 32 50 31.3 50 30.85 49.5"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 18.5 10.85 22.75 9.45 L26.15 12.95 Q21.25 14.05 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 23.45 42.5 32 42.5 40.55 42.5 46.55 37.7 L46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 42.75 14.05 37.9 12.95 L41.25 9.45 Q45.5 10.85 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.05 37 32 37 24.85 37 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q23.65 16.05 28.4 15.3 L28.7 15.6 Q30 17 32 17 33.85 17.05 35.3 15.65 L35.3 15.6 35.6 15.3 Q40.5 16.05 44.2 19 L44.15 19 M30.85 13.5 L24.45 6.85 Q24 6.35 24 5.65 24 4.95 24.45 4.5 24.9 4 25.6 4 L38.4 4 Q39.05 4 39.55 4.5 40 4.95 40 5.65 40 6.35 39.55 6.85 L33.15 13.5 Q32.65 14 32 14 31.3 14 30.85 13.5 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 17.8 11.4 21 10.1 L21 10.35 Q21 12.25 22.25 13.5 L22.75 14 Q19.85 15.15 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 L21.25 40.15 Q21 40.8 21 41.65 21 43.5 22.25 44.85 L22.3 44.95 28.7 51.6 Q30 53 32 53 33.85 53.05 35.3 51.65 L35.3 51.6 41.7 44.95 41.8 44.85 Q43 43.5 43 41.65 L42.8 40.15 46.55 37.7 46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 44.1 15.15 41.3 14 L41.7 13.6 Q43 12.35 43 10.35 L43 10.1 Q46.2 11.4 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.35 36.75 32.8 37 L31.2 37 Q24.55 36.75 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q24.7 15.2 31.2 15 L32.8 15 Q39.45 15.25 44.2 19 L44.15 19 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30.85 2.5 Q31.3 2 32 2 32.65 2 33.15 2.5 L39.55 9.15 Q40 9.65 40 10.35 40 11.05 39.55 11.5 39.05 12 38.4 12 L25.6 12 Q24.9 12 24.45 11.5 24 11.05 24 10.35 24 9.65 24.45 9.15 L30.85 2.5 M30.85 49.5 L24.45 42.85 Q24 42.35 24 41.65 L24.05 41.3 24.45 40.5 Q24.9 40 25.6 40 L38.4 40 Q39.05 40 39.55 40.5 L40 41.3 40 41.65 Q40 42.35 39.55 42.85 L33.15 49.5 Q32.65 50 32 50 31.3 50 30.85 49.5"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

+6
View File
@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 18.5 10.85 22.75 9.45 L26.15 12.95 Q21.25 14.05 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 23.45 42.5 32 42.5 40.55 42.5 46.55 37.7 L46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 42.75 14.05 37.9 12.95 L41.25 9.45 Q45.5 10.85 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.05 37 32 37 24.85 37 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q23.65 16.05 28.4 15.3 L28.7 15.6 Q30 17 32 17 33.85 17.05 35.3 15.65 L35.3 15.6 35.6 15.3 Q40.5 16.05 44.2 19 L44.15 19 M30.85 13.5 L24.45 6.85 Q24 6.35 24 5.65 24 4.95 24.45 4.5 24.9 4 25.6 4 L38.4 4 Q39.05 4 39.55 4.5 40 4.95 40 5.65 40 6.35 39.55 6.85 L33.15 13.5 Q32.65 14 32 14 31.3 14 30.85 13.5 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,6 @@
<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs/>
<g>
<path stroke="none" fill="#FFFFFF" d="M43 50 Q43 52.5 39.75 54.25 36.55 56 32 56 27.5 56 24.25 54.25 21 52.5 21 50 L21 47.9 Q17.8 46.55 15 44.3 8 38.7 8 30.65 L8 30.1 8 29.55 8 29 8 28.5 8 28.1 8 27.95 8 27.4 Q8 19.4 15 13.65 17.8 11.4 21 10.1 L21 10.35 Q21 12.25 22.25 13.5 L22.75 14 Q19.85 15.15 17.4 17.1 L17.45 17.1 Q12.15 21.4 12 27.4 12.1 33.45 17.4 37.65 L21.25 40.15 Q21 40.8 21 41.65 21 43.5 22.25 44.85 L22.3 44.95 28.7 51.6 Q30 53 32 53 33.85 53.05 35.3 51.65 L35.3 51.6 41.7 44.95 41.8 44.85 Q43 43.5 43 41.65 L42.8 40.15 46.55 37.7 46.6 37.65 Q51.9 33.4 52 27.4 51.85 21.4 46.55 17.1 44.1 15.15 41.3 14 L41.7 13.6 Q43 12.35 43 10.35 L43 10.1 Q46.2 11.4 48.95 13.65 56 19.4 56 27.4 L56 27.95 56 28.1 56 28.5 56 29 56 29.55 56 30.1 56 30.65 Q56 38.7 48.95 44.3 46.2 46.55 43 47.9 L43 50 M44.15 19 Q47.7 22 48 25.95 L48 26.05 Q47.7 30 44.2 32.9 L44 33.05 Q39.35 36.75 32.8 37 L31.2 37 Q24.55 36.75 19.8 32.95 L19.7 32.9 Q16.3 30 16 26.1 L16 26.05 Q16.25 22 19.85 19 L19.95 18.9 Q24.7 15.2 31.2 15 L32.8 15 Q39.45 15.25 44.2 19 L44.15 19 M30 27 L30 23 33 23 Q33.85 23 34.4 23.55 35 24.15 35 25 35 25.85 34.4 26.4 33.85 27 33.05 27 L30 27 M33 30 L34 29.9 34 30 35 33 38 33 36.5 28.5 Q38 27.05 38 25 38 22.95 36.5 21.45 35.05 20 33 20 L27 20 27 33 30 33 30 30 33 30 M30.85 2.5 Q31.3 2 32 2 32.65 2 33.15 2.5 L39.55 9.15 Q40 9.65 40 10.35 40 11.05 39.55 11.5 39.05 12 38.4 12 L25.6 12 Q24.9 12 24.45 11.5 24 11.05 24 10.35 24 9.65 24.45 9.15 L30.85 2.5 M30.85 49.5 L24.45 42.85 Q24 42.35 24 41.65 L24.05 41.3 24.45 40.5 Q24.9 40 25.6 40 L38.4 40 Q39.05 40 39.55 40.5 L40 41.3 40 41.65 Q40 42.35 39.55 42.85 L33.15 49.5 Q32.65 50 32 50 31.3 50 30.85 49.5"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB