elParaguayo / qtile-extras

Somewhere to store things I create for qtile that probably won't end up in the official repo
MIT License
163 stars 19 forks source link

Visualizer widget error #121

Closed DeeeeLAN closed 1 year ago

DeeeeLAN commented 1 year ago

I got the following error in the logs after adding the visualizer widget. I have not played any music yet:

2022-09-30 14:33:49,877 ERROR libqtile loop.py:_handle_exception():L63 Got a 8000 bytes buffer, needs at least 9200.
Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/lib/python3.10/site-packages/libqtile/core/manager.py", line 862, in f
    func(*args)
  File "/usr/lib/python3.10/site-packages/libqtile/bar.py", line 616, in _actual_draw
    i.draw()
  File "/usr/lib/python3.10/site-packages/qtile_extras/widget/visualiser.py", line 209, in draw
    self._draw()
  File "/usr/lib/python3.10/site-packages/qtile_extras/widget/visualiser.py", line 213, in _draw
    surface = cairocffi.ImageSurface.create_for_data(
  File "/usr/lib/python3.10/site-packages/cairocffi/surfaces.py", line 743, in create_for_data
    return cls(format, width, height, data, stride)
  File "/usr/lib/python3.10/site-packages/cairocffi/surfaces.py", line 730, in __init__
    raise ValueError('Got a %d bytes buffer, needs at least %d.'
ValueError: Got a 8000 bytes buffer, needs at least 9200.
elParaguayo commented 1 year ago

Very odd. That shouldn't be possible!

Did you change any settings for the widget?

DeeeeLAN commented 1 year ago

Nope, literally just updated the package, added the default widget and dependency, and checked the logs. I have since played music and nothing popped up.

elParaguayo commented 1 year ago

By "dependency" I assume you mean you've installed cava? It sounds like that command isn't running properly so can you just try running cava in a terminal and see if it works?

DeeeeLAN commented 1 year ago

Yes cava, it looked like it ran fine yesterday, although I only ran it for a couple seconds without any music.

elParaguayo commented 1 year ago

Hmm. Can you try making it smaller e.g. width=50, bars=4?

DeeeeLAN commented 1 year ago

Changing the width scaled the error message to match:

width=100 -> Got a 8000 bytes buffer, needs at least 9200.
width=50  -> Got a 4000 bytes buffer, needs at least 5200.
width=25  -> Got a 2000 bytes buffer, needs at least 3200.

Changing bar number didn't make a difference.

Just checked and Cava runs fine in the terminal.

elParaguayo commented 1 year ago

Hmm. So we're always 1200 bytes off. I've no idea why that number isn't changing.

However, looking at the numbers, I think you're getting the right size: 100 (width) x 20 (height - default) x 4 (ARGB) = 8000 bytes. So why does Cairo want you to have more on your system?

elParaguayo commented 1 year ago

I think I know where the bug is: Have you got a widget decoration with the visualiser?

If I'm right #124 should fix this.

DeeeeLAN commented 1 year ago

Yep, I have a powerline decoration on it.

elParaguayo commented 1 year ago

Great. Can you test the PR and let me know if that works? Pretty sure it will!

elParaguayo commented 1 year ago

Actually, I've just tested this myself. I can recreate the issue and the PR does fix it. Will get it merged soon.

DeeeeLAN commented 1 year ago

I don't get an error anymore, but I also don't have the widget showing up at all either. Nothing in the logs mentioning it.

elParaguayo commented 1 year ago

Output of ps aux | grep cava and qtile cmd-obj -o widget visualiser -f eval -a "self._procs_started"?

DeeeeLAN commented 1 year ago

hmm

> ps aux | grep cava
dillan     47096  0.6  0.0 232420 10904 tty1     Sl   13:42   0:01 /usr/bin/cava -p /tmp/tmp5v_qpf31
dillan     47098  0.4  0.0  42496 27512 tty1     S    13:42   0:00 python /usr/lib/python3.10/site-packages/qtile_extras/resources/visualiser/cava_draw.py --width 100 --height 20 --bars 8 --spacing 2 --pipe /tmp/cava.pipe --background #ffffff
dillan     47866  0.0  0.0   6564  2484 pts/1    S+   13:45   0:00 grep cava
> qtile cmd-obj -o widget visualiser -f eval -a "self._procs_started"
(True, 'True')
elParaguayo commented 1 year ago

OK. So the processes are all running. What about qtile cmd-obj -o widget visualiser -f info?

DeeeeLAN commented 1 year ago
> qtile cmd-obj -o widget visualiser -f info
{'height': 75,
 'length': 115,
 'name': 'visualiser',
 'offset': 3845,
 'width': 115}
DeeeeLAN commented 1 year ago

Here is my visualizer config:

visualizer_config = dict(
    hide=False,
    background='#BC83E37F',
    bars=8,
    width=100
)
DeeeeLAN commented 1 year ago

Duh, sorry I got it working. I had only added it to my second screen which is disabled. Thanks for the help.

elParaguayo commented 1 year ago

Interesting. If the screen is disabled. Why is the widget running?

DeeeeLAN commented 1 year ago

Fake screen? Or because I create the widget outside of the screen then pass it into the widget array for the screen?

elParaguayo commented 1 year ago

The processes would only start when the widget is configured which, in turn, happens when the bar is configured. That should only happen if the bar is on an active screen.

DeeeeLAN commented 1 year ago

Odd. I assume it will be easy to recreate if you want to test it though. Just create a fake screen that does not get displayed because it is outside the range of your active screen, then give it some widgets that are not on the active screen. That is basically how I had it set up.

elParaguayo commented 1 year ago

Ah. Ok. Now I understand. Yes, that would start the widget.