Mercurial > code > home > repos > racc
view volume_linux.py @ 2:0ecb388a0b90
start power code
author | drewp@bigasterisk.com |
---|---|
date | Sat, 04 Mar 2023 12:10:36 -0800 |
parents | 04c8a1b3976b |
children |
line wrap: on
line source
from pulsectl_asyncio import PulseAsync _pulse = None async def _init(): global _pulse if _pulse is not None: return _pulse = PulseAsync('racc') await _pulse.connect() async def _get_sink(): [sink] = [ s for s in (await _pulse.sink_list()) if s.description == 'Built-in Audio Analog Stereo' ] return sink async def get_volume(): await _init() return (await _get_sink()).volume.value_flat async def set_volume(v: float): await _init() sync = await _get_sink() await _pulse.volume_set_all_chans(sink, v)