Einar's blog

Setting the background wallpaper for Sway and managing music with Emacs

I just watched an old video by Luke Smith which gave me the idea that it would be cool to change background in Sway from Emacs. I thought I would use dired and either open an image to see how it looks directly or use image-dired to get a preview of all the images in a folder. I would probably have to make a shell script to do the work and launch it with async-shell-command from an elisp function. It turns out I don't have to do anything. The functionality is already built into Emacs and it even gets which window manager or desktop environment is in use and selects the correct command to change the background for that WM or DE. The documentation tells me this functionality came with Emacs 29.1, at the same time a lot of other improvements were made to image-dired and opening images in general. I used image-dired in 28.2 and the improvements with 29.1 were many and greatly appreciated!

A few months ago I did the same type of discovery. I was looking for a way to interact with mpd, the music player daemon, possibly through the command line tool mpc from within Emacs. EMMS and Bongo are often mentioned by people in the Emacs community and I have tried both, but they are both unable to list albums with many artists and/or many recording years as one album. All other mpd players I have tried, both TUI and GUI-based have the same problem, so this is not a unique shortcoming in these packages. Maybe mpd has some shortcomings when it comes to listing albums. So, until recently, I have relied on a shell script I wrote that lists all the albums in the mpd database with fzf and lets me select the one I want to play. However, sometimes I don't want to play a whole album, but I still want my music sorted by album since I have been carefully tagging my files so I can easily find music by album.

(I kind of had to make a system for album names since having 11 albums named "Bach cello suites" doesn't really help me find the one I like to listen to when I have six different recordings, they span two albums and two recordings are by the same artist at different times. Another example is that Bach: Keyboard Concertos is too vague for me to know which Bach (J. C., J. S. and C. Ph. E. are in my database), which concertos (I have some of J.S.' and some of C. Ph. E.'s) and which performers (I have at least one of them in two recordings with different artists). Hence, I have made a system that is fine grained enough for me to find the right album without being too detailed to avoid too long album names, for instance, I don't include first name initials of the composer in the album name when I only have one composer with that last name in my database and I don't list artist when I have only one recording of a work. Every time I ripped an album, I manually changed the tags to match my system even if MusicBraniz through Rhythmbox and earlier, iTunes, often gave me terrible album names for classical albums when I ripped them, otherwise I would not be able to find anything.)

A few months ago, I discovered a built-in mpc mode in Emacs that gave me exactly what I wanted. I could continue to use mpd and mpc to manage my music playback and use mpc mode which looks very much like Rhythmbox, but has the advantage of having all of Emacs' superior keyboard centricity and text handling. I can easily search with C-s for an album name, add it to the playlist and start playing it and then q to quit out of that mode with the music still playing and I am back at whatever I was doing in Emacs before, all without having to lift my hands from the keyboard. It is really convenient. In mpc mode, the albums are correctly listed even when there are many artist and/or years on the same album. Since I can sort my music by album, I can easily also find a single track if I am so inclined.

These kinds of discoveries make me love Emacs and the Emacs community. Emacs is hackable enough that if you want some functionality, you can get it. And since the project wasn't started yesterday, someone has often already thought of my use-cases and spent some of their spare time to code up that functionality and often also even gone to the trouble to include it in the editor itself. Thank you!



All content is shared under the terms of the Creative Commons Attribution-ShareAlike license.