karlstav / cava

Cross-platform Audio Visualizer
MIT License
4.27k stars 231 forks source link

Two squares on top of each bar in Tmux #577

Open pcarrin2 opened 3 months ago

pcarrin2 commented 3 months ago

Describe the bug

On my TTY, cava renders perfectly. However, in tmux, there are two boxes on top of each bar instead of a normal bar cap, like in https://github.com/karlstav/cava/issues/553. The workaround from that issue simply crashes cava.

If I set the (NixOS) system locale to en_US.iso8859-1 (slightly extended ASCII), then cava still runs fine on the tty but fails to run at all in tmux (blank screen). If I set the system locale to iso8859-1, run inside tmux, and locally change the locale to utf8 in cava's environment, it displays ASCII dashes instead of the box drawing glyphs that it does on a bare tty.

To Reproduce

Steps to reproduce the behavior:

  1. Open tmux on a Linux tty
  2. Run cava
  3. See ugly double-squares on top of bars

Or:

  1. Set system locale to something non-utf8
  2. Run cava inside tmux
  3. See that cava fails to display anything!

Expected behavior

Since other programs can draw boxes just fine inside tmux, I would expect cava to do the same thing, with box caps appearing properly.

Specs

cava built from source by NixOS. OS: NixOS Stable Environment: tmux over tty Hardware: thinkpad t14s For more configuration info, see https://github.com/pcarrin2/nixos

pcarrin2 commented 3 months ago

One fix would be to add a config option to disable the 1/8 and 7/8 bar tops, since I believe those are the only chars my terminal can't render!

karlstav commented 3 months ago

hi @pcarrin2,

sorry about the late response.

I can confirm this.

In a tty all the block characters are usually not available, cava solves this by using a custom font where some of the characters are custom made. The issue is that when running tmux in a tty the terminal is no longer considered a tty, We would need to find some other way for cava to detect if it is in a tty. Or maybe a config option to force "tty mode".

karlstav commented 2 months ago

try setting this to 1:

https://github.com/karlstav/cava/blob/395b36e75b2e8c2b35349e01f24719b61c42b10a/cava.c#L296

if it works I can create a config option to force "tty mode"

jamescraft10 commented 1 month ago

is there a way to just not render the bars on the top?

karlstav commented 1 month ago

no, but this can most likely be solved by either adding a config option to force tty mode. Or finding a better way to detect if in a ttty.