Skip to content

Commit

Permalink
pulse: make lock non-global
Browse files Browse the repository at this point in the history
If users have multiple pulse widgets in their bar, we may silently ignore
_configure() requests and never configure widgets, which will result in
them never rendering their state.

Signed-off-by: Tycho Andersen <[email protected]>
  • Loading branch information
tych0 committed Dec 8, 2024
1 parent a49ed89 commit 80b1123
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions libqtile/widget/pulse_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
from libqtile.utils import create_task
from libqtile.widget.volume import Volume

lock = asyncio.Lock()


class PulseConnection:
"""
Expand All @@ -47,10 +45,11 @@ def __init__(self):
self.callbacks = []
self.qtile = qtile
self.timer = None
self.lock = asyncio.Lock()

async def _configure(self):
# Use a lock to prevent multiple connection attempts
async with lock:
async with self.lock:
if self.configured:
return

Expand Down Expand Up @@ -79,7 +78,7 @@ async def _check_pulse_connection(self):
await self.pulse.connect()
logger.debug("Connection to pulseaudio ready")
except PulseError:
logger.warning("Failed to connect to pulseaudio, retrying in 10s")
logger.exception("Failed to connect to pulseaudio, retrying in 10s")
else:
# We're connected so get details of the default sink
await self.get_server_info()
Expand Down

0 comments on commit 80b1123

Please sign in to comment.