Show HN: kew – A Terminal Music Player for Linux

github.com

144 points by ravachol 2 days ago

Hi HN,

I created kew, a music player for the Linux terminal.

This started when I asked myself: what if I could just type something like "play nirvana" in the terminal and have the rest taken care of automatically? That got the ball rolling and I kept adding stuff: covers in ascii and then as sixel images, a playlist view, a visualizer, a library view and finally search.

While kew can be used as a commandline tool, it has evolved into a TUI app.

Here are some example commands:

kew nirvana # Plays all of your Nirvana songs, shuffled

kew nevermind # Plays the "Nevermind" album in order

kew spirit # Plays "Smells Like Teen Spirit"

kew all # Plays all your music, shuffled

kew albums # Plays one album after the other in random order

It works best when your music library is organized like this: Artist/Album(s)/Track(s)

kew is written in C and licensed under GPLv2.

Source and screenshot: https://github.com/ravachol/kew

kunley 2 days ago

Apart from all the audio goodies, that's one of the few projects around that has actually working make uninstall.

So much thanks for giving a good example

  • ravachol 2 days ago

    You uninstalled it. :(

    • kunley 2 days ago

      No, I didn't! But I was happy to see such a makefile target exists and one doesn't need to go through console logs to see wtf was installed, or just shrug and think "yet another project made like it's the center of the universe"

      • ravachol 2 days ago

        Oh ok, my bad! And GOOD.

        I agree it's important. kew is so small it was pretty trivial to do.

BoingBoomTschak 2 days ago

It's is pretty cool, I can feel the energy poured into making your personal computing experience more seamless! Though the first thing I wondered when reading your examples is "how is ambiguity resolved?". Like albums, artists and tracks having the same string or sharing a prefix (search in this specific order, I guess?); or artists having the exact same name.

The aspect I like the most is using the filesystem as a database, since that's what UNIX people should like (and you can use symlinks for more complex cases). In fact, I myself made a music player with that as central philosophy, though it is much more bare/suckless compared to yours: https://git.sr.ht/~q3cpma/mus

Did you consider implementing a simple event system (maybe even IPC) for track and status change? Possibly MPRIS or something simpler. That was the main feature I kept from cmus when creating mus, so that I can easily interact with it through lemonbar and scripts.

  • ravachol 2 days ago

    Thank you. To answer your first question, ambiguity isn't resolved unfortunately. When the album has the same name as the artist for instance, I have sometimes resorted to renaming the album name by adding "album" to it. You can however get an exact search by adding -e so that resolves some problems.

    Yes, MPRIS is supported.

theandrewbailey 2 days ago

    sudo bash -c "curl https://raw.githubusercontent.com/ravachol/kew/main/install.sh | bash"
Might as well run unsigned binaries straight from the internet. What is this, Windows?
  • ravachol 2 days ago

    Good point. Might be better to just have the commands installing the requirements for the different distros, in the readme.

  • shepherdjerred 2 days ago

    Super weird to bring Windows into this, but, anyway? I actually really like these one liners even if they have greater potential for abuse.

    • halJordan 2 days ago

      It's not weird to mention the other os where downloading and blindly double-clicking a naked exe is the standard.

      • shepherdjerred 2 days ago

        Users do the exact same on macOS, Android, iPhone, and Linux

    • ravachol 2 days ago

      He's right actually the quick-install script is pretty barbaric.

cdaringe 2 days ago

I love the idea. My music is now 50% cloud only, 50% on disk. I mean, its 100% in the cloud, i just have local files for half available. Ive been thinking about self hosting some music provider thingy (or even just supporting ssh via my dyndns-like capability) to my NAS and bringing music back to self owned files. However, it is work to do when the internet is pretty reliable, costs are low, etc.

Those who love this conceptually but have/had cloud music, did you act? How/why?

  • raun1 a day ago

    I host my music on an Unraid box on my home LAN, use Plex+Plexamp to serve and access it, and 1000% recommended Plex+Plexamp. It is, without a doubt, the best music app I've used on a phone, including other self-hosting solutions, local apps like Poweramp, and commercial streaming apps like Spotify. I really can't speak of it highly enough.

  • nvllsvm 2 days ago

    I used various Subsonic clients for a number of years, but the clients were always lacking. Android clients were buggy or didn't prioritize local caching and I preferred to use mpd+ncmpcpp on my laptop.

    I ended up switching to fully-local media after realizing that my 956GB flac+mp3 would be ~159GB when converted to Opus. I now use https://github.com/nvllsvm/harmonize to maintain a 128kbps Opus version of my main library and Syncthing to synchronize it to my phone and laptop.

    --- side note, Auxio is the client I'm using on Android with my synced library.

  • reverend_gonzo 2 days ago

    I have a airsonic (fork of subsonic, which I used for a long time) server running on a vps. I’ve probably had this for coming on 20 years now.

    It works phenomenally.

    At some point I was going to mirror it locally, but never got around to it.

    It is all backed up in dropbox

    • lunchables 2 days ago

      I've also been a long time airsonic (and now airsonic-advanced) user for so long I can't even remember, but a couple years ago I switched to navidrome which is also subsonic compatible and it's sooo much nicer.

      Use whatever you want! Just wanted to suggest it.

jakobdabo 2 days ago

I see what you've done there!

        int randomNumber = getRandomNumber(1, 808);
        if (randomNumber == 808)
                printGlimmeringText(text, nerdFontText, lastRowColor);
Nice project!
  • ravachol 2 days ago

    That's an easter egg! Gj! You're the first that has mentioned it.

VyseofArcadia 2 days ago

Slick! I love it.

It doesn't fit my use-case very well, though. I'm not saying it needs to, but I'm going to put my use-case out there in case someone is looking for project ideas.

We have oodles of music players on Linux, GUI and terminal. But we have very few choices that

* are optimized for the absurdly, comically large library of someone who has been diligently collecting and organizing music for decades

* collect playback statistics and allow user rating of songs

* that can be used to create smart playlists

I used amarok for years, but it keeps dying and reviving, and I don't trust it to stick around. I then used mpd for years, but while mpd excels at large libraries, the other two requirements have to be implemented client-side, and the experience was always at least a little janky. I currently use Strawberry, but 1) it chugs with a large library, 2) its smart playlists aren't expressive enough, and 3) it is also kind of janky, and I experience frequent crashes.

The only player I've found that really fits my use-case like a glove is MediaMonkey, but I walked away from Microsoft years ago, and I'm not about to go back now just to wrangle my music library.

  • sandreas 2 days ago

    Nice, thanks for sharing your thoughts. Currently, I use navidrome[1], which not really is a player but more a music server, but since it supports the "subsonic" protocol, you can use native apps to connect and manage your stuff (substreamer for android / iOS is all I really need but navidrome also comes with a handy web interface). It also has support for json based smart playlists[2].

    1: https://www.navidrome.org/ 2: https://github.com/navidrome/navidrome/issues/1417

    • worble 2 days ago

      Just to add an alternative, I'm using Airsonic Advanced[0] as my subsonic server of choice if for only one reason: it properly supports folder navigation. I've ranted about this before (looking at you Jellyfin) but my folder layout is sacred and any media service I use needs to respect it.

      For an android client I use tempo[1] which again was one I landed on because pretty much all the other clients didn't support folder lookup either (I think dsub also does but tempo is a lot prettier).

      0: https://github.com/kagemomiji/airsonic-advanced

      1: https://github.com/CappielloAntonio/tempo

    • VyseofArcadia 2 days ago

      That looks like it checks most of my boxes, but I have a personal/philosophical objection to running a service. The objection is, I don't want to[0]. I just want a local application. Not local-first, I want local-only. Just an application.

      [0] and also I think it's insane to add that much complexity to something that is single-user.

      • lunchables 2 days ago

        I'm also a navidrome user and I run it via docker exposed via traefik so I can access my music anywhere. I can use any subsonic client on android or iOS and I can bluetooth that to my car or headphones or whatever and I can load it up on my laptop anywhere.

        As you've said you just want a local application just wanted to mention that in case that's actually something that might also be useful for you.

      • sandreas 2 days ago

        Totally understandable. I recently thought of developing a cross platform player in C# and AvaloniaUI, but cross platform audio is not as easy as it seems, especially trying to use open source libs only and minimizing dependencies.

  • ravachol 2 days ago

    Yes, while a comically large music library is supported in principle (kew offers to cache your library if it takes a long time to search through), it might not be entirely suited for it.

    As for your other two suggestions those fall outside the scope of kew. kew is supposed to be simple with minimal bloat.

    • VyseofArcadia 2 days ago

      I will by trying it out on my laptop which has only a fraction of my library and I don't use often enough to want statistics or smart playlists.

  • amlib 2 days ago

    Strawberry is a pretty solid Amarok fork that is picking up steam. They are now releasing multiple releases a month and in my opinion it's a great "fully featured", gui first, easy to use player that handles large libraries well.

    • opan 2 days ago

      Amarok? Not Clementine? Or was that also an Amarok fork?

sigmonsays 2 days ago

Trying to nix run it I get a ton of insecure warnings and it lists the CVEs

Is this a nix thing (i'm unsure what freeimage-unstable is)

       error: Package ‘freeimage-unstable-2021-11-01’ in /nix/store/20yis5w6g397plssim663hqxdiiah2wr-source/pkgs/development/libraries/freeimage/default.nix:72 is marked as insecure, refusing to evaluate.


       Known issues:
        - CVE-2021-33367
        - CVE-2021-40262
        - CVE-2021-40263
        - CVE-2021-40264
        - CVE-2021-40265
        - CVE-2021-40266
        - CVE-2023-47992
        - CVE-2023-47993
        - CVE-2023-47994
        - CVE-2023-47995
        - CVE-2023-47996
  • ravachol 2 days ago

    FreeImage is used by Chafa to display the covers in the terminal.

    The version of kew packaged for Nix is very old: v1.5.2. We're at version 2.8.2. So it's more than a year old, from very early on in the project.

  • ravachol 2 days ago

    "Buffer Overflow vulnerability in Freeimage v3.18.0 allows attacker to cause a denial of service via a crafted JXR file."

    I don't know how relevant these vulnerabilities are to kew, which isn't run across the network in any way, it just reads your local files.

    Thank you for bringing this to light. I don't know how feasible it is to use something other than freeimage though, gonna have to investigate.

    • joveian 2 days ago

      It is still relevant because sometimes those local files come from the network and aren't trusted.

      Looks like a nice project, I like the terminal album art display :).

retrodaredevil 2 days ago

I've been using Plexamp for the past 4 years, and its been great for music on my phone and computer. One thing it lacks is a good offline mode. Recently I started syncing my media to my laptop as a backup, and as a way to locally play 5.1 FLAC audio (Plexamp doesn't support 5.1 audio).

I'll have to check this out. I wonder if it can play 5.1 audio correctly?

smartmic 2 days ago

I use mpd with various clients, mostly also from terminal. mpd support would be great - and actually the only reason for me to try it out.

https://www.musicpd.org/

udev4096 2 days ago

I personally use a self hosted musikcube server [0] for playing songs. It has a great TUI and an android app. Highly recommended!

[0] - https://musikcube.com/

yarg 2 days ago

Does it accept flags to deal with ambiguities?

Defaulting to the only result in your library is perfectly reasonable, but it the case of a collision, what does it do?

My guess is that it runs through in a loop (I haven't looked at the code) and simply goes with the first result that it finds, but that doesn't cover all possible use cases.

  • ravachol 2 days ago

    Like you said, it just takes the first result it finds. There is -e for exact search, which solves some problems, but it's not a full blown solution.

    • yarg 2 days ago

      I'm thinking {-s, -l, -a, -p} for {song, album, artist, playlist}.

      Unlike the -e solution, it wouldn't make the command significantly more verbose than the default option.

      You could also print a list of commands for the specific options (or allow for index based selection) in cases where there were collisions.

      • ravachol 2 days ago

        That's already mostly in. From the readme:

        kew dir <album name> (sometimes it's necessary to specify it's a directory you want)

        kew song <song> (or a song)

        kew list <playlist> (or a playlist)

        The directory can be an artist or an album, so there's still ambiguity there. But kew cannot differentiate between the two. It matches against files or against directories.

        • yarg 2 days ago

          Yeah, to fix that you'd need to add support for media metadata, which I imagine is a little further than you'd want to go.

martinbaun 2 days ago

This is exactly what I was looking for! I actually started writing something myself.

And I "compiled from source" as I am using Fedora, but it was just one command.

Thank you!

  • ravachol 2 days ago

    Glad you are liking it!

    • martinbaun a day ago

      I love it man, this is great! I used to use mocp but I could never get it to work on Fedora.

      This here is even better, I love the minimal approach.

      • ravachol a day ago

        That's great! Get involved if you want and suggest features for instance.

edgarvaldes 2 days ago

Random album is great. Few players do it right.

atrus 2 days ago

I love the readme, and I wish that every project had one this great. And it player looks awesome as well!

  • politelemon 2 days ago

    I agree, the README makes me want to try it tonight when I get home. This project is very interesting and worth trying.

  • ravachol 2 days ago

    Thanks, yes the readme is really important. A lot of projects would benefit from spending a bit more time on it.

mass_and_energy 2 days ago

Hmm I wonder how hard this would be to hook into my Jellyfin server, has anybody tried?

n2j3 2 days ago

Cool, but does it scrobble?

  • ravachol 2 days ago

    kew does not scrobble. It does not track any of your listening habits or anything else for that matter.

kopirgan 2 days ago

Requires Debian 13?

  • ravachol 2 days ago

    You know I'm not sure. I think there was some problem with FFmpeg in earlier versions, but I'm not 100% sure. There shouldn't be a problem trying to install it in earlier versions though.

fallat 2 days ago

But can we make it smaller

whoomp12342 2 days ago

great, now my coworkers will have a new interesting way of rick rolling me -> while I run my build scripts

leapon 2 days ago

brew install failed on macos

% brew install kew

...

kew: Linux is required for this software.

Error: kew: An unsatisfied requirement failed this build.

  • ravachol 2 days ago

    Yes, unfortunately it only works on Linux and FreeBSD. I should add that to the readme.

    EDIT: Added.

    • jeffhuys 2 days ago

      Why, though?

      • ravachol 2 days ago

        Because I'm just one guy with a few people helping me a little bit. I needed a limited scope. But I'm actually thinking of porting it to Mac now.

        • jeffhuys 2 days ago

          I don’t think you need to port that much as macOS is based om freeBSD

      • jhatemyjob 2 days ago

        Cus they like Stallman too much