Cmus alphabetization

cmus has been my faithful music player for well over a decade now. It lists your artists and lets you play their music: kind of hard to fuck up, unless you're Apple. After my laptop was force upgraded to MacOS Sequoia, I found that every artist with a unicode name was grouped together by string length. For example, albums by ГШ (Russian), 王菲 (Chinese), and 天鼓 (Japanese) all appeared under the same name—here "ГШ". The "world music" bin strikes again! Needless to say, this completely kneecapped my ability to browse non-English music.

Why man

I don't particularly care. This isn't one of those technical deep dives. I don't enjoy topics like this, sorry. If you're reading this, perhaps you just want the problem to go away like I did. Long story short is that Apple updated the behavior of strcoll() to weight unicode glyphs differently, which affects cmus' grouping. Maybe this isn't even Apple's fault, but I'm still pissed at them for rebooting me without consent and causing this headache.

Fix it

Running cmus with different locale values, such as the old C style collation, does not work.

LC_COLLATE=C cmus

cmus overrides this value to the system default. Don't bother with LC_ALL=C either, since that will just render text as "????". Mixing various other env vars yielded no solutions. You have to rebuild from scratch.

I first removed my homebrew install of cmus.

brew uninstall cmus

Then I cloned the source.

git clone https://github.com/cmus/cmus

You only have to change one line in ui_curses.c.

setlocale(LC_COLLATE, "");

should become

setlocale(LC_COLLATE, "C");

in order to use a nice dumb ordering/grouping of unicode text.

Install it

I had trouble actually building it with Monkey's Audio (.ape), so I removed this from the configuration.

./configure CONFIG_APE=n

After the config script ran, I did

make
sudo make install

This installed cmus to /usr/local/bin, which is different from homebrew's behavior.

Audio output didn't work at first. When I ran cmus --plugins I could see

Output Plugins: /usr/local/lib/cmus/op
  coreaudio
  ao

but I had to run

:set output_plugin coreaudio

in cmus itself.

Everything seemed okay after that. I'm waiting for something else to subtly fuck up, but at least I can find my music now.

Postscript

  1. I basically never upgrade anything these days due to shit like this.
  2. I arrived at this solution with the help of ChatGPT. I don't think LLMs are amazing, but they're a worthy successor to Google, which has intentionally rendered itself useless.