frobar: Handle PulseAudio sinks without active port

No idea in which conditions those happen, but apparently they do happen.
This commit is contained in:
Geoffrey Frogeye 2025-01-11 15:01:46 +01:00
parent d6e95da9dc
commit 3ccb0abfe5
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
2 changed files with 9 additions and 6 deletions
hm/desktop/frobar/frobar

View file

@ -531,6 +531,10 @@ class MultiSectionsProvider(Provider):
async def getSectionUpdater(self, section: Section) -> typing.Callable:
raise NotImplementedError()
@staticmethod
async def doNothing() -> None:
pass
async def updateSections(self, sections: set[Sortable], module: Module) -> None:
moduleSections = self.sectionKeys[module]
async with asyncio.TaskGroup() as tg:

View file

@ -432,7 +432,11 @@ class PulseaudioProvider(
sink = self.sinks[section.sortKey]
if (
icon = "?"
if sink.port_active is None:
pass
elif (
sink.port_active.name == "analog-output-headphones"
or sink.port_active.description == "Headphones"
):
@ -444,8 +448,6 @@ class PulseaudioProvider(
icon = ""
elif sink.port_active.name in ("headset-output", "headphone-output"):
icon = ""
else:
icon = "?"
section.numberStates = 3
section.state = 1
@ -497,9 +499,6 @@ class NetworkProvider(
self.time = loop.time()
self.io_counters = psutil.net_io_counters(pernic=True)
async def doNothing(self) -> None:
pass
@staticmethod
def getIfaceAttributes(iface: str) -> tuple[bool, str, bool]:
relevant = True