Skip to content

Mouse callbacks in Qtile bar won't work

Hi, I've been working on my first rice in Qtile, and there's a problem that I couldn't solve. I tried to add mouse callbacks for some of my bar widgets, but I just couldn't get it to work.

Here's the snippet for opening pavucontrol when clicking on the volume widget:

def open_pavu(qtile):
    qtile.cmd_spawn("pavucontrol")

topBar = bar.Bar([
                #  ...
                # Volume
                widget.TextBox(
                    text="墳", foreground=colors["green"], fontsize=17,
                    mouse_callbacks={
                        'Button1': open_pavu},
                    volume_app="pavucontrol"),
                widget.Volume(foreground=colors["green"],
                              mouse_callbacks={'Button1': open_pavu},),
                ],
                #  ...
                )
                #  ...

But it just doesn't work.

I tried the stable qtile release, and qtile-git from the AUR, still doesn't work.

How could I fix this?

Edited 18 Jun 2021. We only hold this version.

3 points3 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
3 · 100% up
Kind
Text
ID
o2grcb

Author

38
posts
78
comments
7
media
View profile

3 comments

Apparently, mouse callbacks don't take Qtile arguments anymore, you just need to use

from libqtile import qtile

def open_pavu():
   qtile.cmd_spawn("pavucontrol")
3 points

Try it with a lambda like, I am not 100% if this works, but it would eliminate the need for defining a separate function.

mouse_callbacks = {'Button1': lambda: qtile.cmd_spawn("pavucontrol")},

Also .cmd_spawn accepts a list of strings, instead a string too, if you need arguments to the program. Like ["program", "arg1", "arg2"]

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.