[Swaybar] Cava in swaybar

Jears@social.jears.at to Unixporn@lemmy.ml – 38 points –
social.jears.at

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

3

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

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

>:)

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