qtile: mouse_callbacks not working

Issue description

I cannot, for the life of me, get mouse_callbacks to work with any of my widgets. The goal is to run a bash script when the widget is clicked. However, it seems like qtile is simply not recording my clicks at all.

widget.KeyboardLayout(fmt='  Keyboard: {}', background=colors[1], mouse_callbacks={'Button2': lambda: qtile.cmd_spawn('bash /home/graeme/.local/bin/togglekeyboard.sh')}),

I’ve also tried lazy.spawn, subprocess.run, subprocess.call, and using a non-lambda function. Nothing seems to work.

Qtile version

0.17.0

Stack traces

Nothing relevant was printed to the log.

Configuration

https://github.com/Graeme22/dotfiles

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (23 by maintainers)

Commits related to this issue

Most upvoted comments

Last point that comes to my mind, I haven’t read this part of the code yet, but it seems that at some point we tried (and succeeded?) to draw a widget with a negative length. To log something when that happens could be a fair addition too.

Logging could make sense here, in my case that would’ve tipped me off that my config had two adjacent spacers which I didn’t know nor want. However, I’d assume some people might want that behavior. Intuitively it seems like two adjacent widgets with width stretch should equally divide that space between them.

I used the logger for almost all the variables of this function to finally find a described pr 😄 So, most of the current behavior comes from #1774.

If I understand right, the logic does not take into account the possibility of a block with a length superior to the interval.

In a case like this : Block1, Stretch1, Block2, Stretch2, Blooooooooooooooooooock3 the calculated length of Stretch2 is negative (~interval minus Block3), which makes the calculation of the following offsets wrong. The consequence is that some widgets share the same space, therefore the inoperative mouse_callbacks.

One solution could be to fallback to the previous logic when a block is bigger than the interval. All stretched widgets get equal width by sharing the space left by the non-stretched widgets. We’ll lose the centered effect, which in that case seems impossible to obtain anyway.

Last point that comes to my mind, I haven’t read this part of the code yet, but it seems that at some point we tried (and succeeded?) to draw a widget with a negative length. To log something when that happens could be a fair addition too.

Definitely sounds like something needs to be fixed anyway. 😃