this post was submitted on 28 Dec 2023
38 points (93.2% liked)

Unixporn

15406 readers
20 users here now

Unixporn

Submit screenshots of all your *NIX desktops, themes, and nifty configurations, or submit anything else that will make themers happy. Maybe a server running on an Amiga, or a Thinkpad signed by Bjarne Stroustrup? Show the world how pretty your computer can be!

Rules

  1. Post On-Topic
  2. No Defaults
  3. Busy Screenshots
  4. Use High-Quality Images
  5. Include a Details Comment
  6. No NSFW
  7. No Racism or use of racist terms

founded 5 years ago
MODERATORS
38
[Swaybar] Cava in swaybar (social.jears.at)
submitted 10 months ago* (last edited 10 months ago) by jeremias@social.jears.at to c/unixporn@lemmy.ml
 

Distro: Gentoo

WM: Sway

Bar: Swaybar

It seems swaybar gets very little love, but it is honestly amazing how easily customizable it is.

I have only been able to find similar things for waybar, so I thought I should probably just code up a solution for spectrum visualization myself.

In the background runs a little selfmade C program that uses cava in binary raw mode, playerctl, pactl and some system functions to gather all the necessary information like the spectrum analyzer, song currently playing, volume and date/time.

Some rudimentary optimization was done to keep swaybar from drawing when the levels haven't changed, so if no audio is playing it takes up basically no computing power.

The source code is pretty hacked together, but if someone wants it, just comment and I'll provide it.

~~A small moving demo of the spectrum analyzer: https://youtu.be/S7IFNHgnybU~~

Edit: turns out YouTube doesn't like weird aspect ratios and stopped processing the video, so here we go again, this time hosted on my server: https://jears.at/pub/swaybar-demo.webm https://jears.at/pub/swaybar-demo.webm

top 3 comments
sorted by: hot top controversial new old
[–] wh0_cares@lemmy.blahaj.zone 2 points 10 months ago (1 children)

Looks dope, can I see the source code? I had cava in my polybar back when I used i3, would love it on sway

[–] jeremias@social.jears.at 2 points 10 months ago (1 children)

Here is the source code of the status commans:

http://sprunge.us/4xaYvq

And here is the relevant cava config: http://sprunge.us/hiY6EA

Don't say I didn't warn ya about quality. Some path are hardcoded in, some are provided with defines. Generally just a big mess.

Comes with the works on my machine, might break yours warranty :D

[–] wh0_cares@lemmy.blahaj.zone 1 points 10 months ago* (last edited 10 months ago)

>:)

I'll happily break my machine to try to get cava on my bar working ~~eventually~~

Skimming thru, doesn't look too bad, but I'm sure I'll find the horrors soon enough