SongPaper
SongPaper is a program I wrote to show the music I’m listening to on my desktop background using the wlr-layer-shell Wayland protocol.
I use SDL3 to create a window, as this hugely simplifies the window creation and rendering process.
Normally, SDL handles the whole window creation process, but for me this wouldn’t work, as I need to attach the surface to a layer, which isn’t a standard thing that SDL supports.
However, luckily for me, there’s a flag called SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN that makes SDL skip some of the initialisation so that I can customise it.
What I need to do is request the wl_surface and wl_display pointers from SDL, and then use those to create a layer shell object and a layer surface from that.
After some extra configuration steps, I now have a window on the desktop background layer.
The next step is setting up an SDL renderer to start drawing. I set up the blend mode so that I can still see my swaybg-provided wallpaper behind the window, and then I can start rendering images over the background.
After adding SDL3_ttf, I can also draw text on it.
To query the current playing song, I can use MPRIS over DBus.
I used the sdbus-c++-xml2cpp tool to generate a C++ interface from the MPRIS specification, and poll it every second from an SDL timer callback.
I can then use this info to load the cover art provided by MPRIS and render it to the screen, as well as laying out text objects for the song’s metadata next to it.
In order to reduce CPU and other resource usage, the main thread will sleep until the timer thread receives new data from DBus polling.

I have also added support for using fontconfig to load system fonts for text rendering, instead of having to provide the file path yourself, and for loading a configuration file using jsoncpp.
I want to add support for autodetecting players, as currently you need to set the player ID in the config file for it to connect to the corrrect DBus service.
I also want to have this run as a systemd service, so that it runs when I log in automatically.
You can view the source code here!