#π How to change volume on linux in py
10 messages Β· Page 1 of 1 (latest)
@sinful oasis
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!pip pulsectl
(I'm assuming you're using pulseaudio/pulse-pipewire as your audio server)
okay, let me try that!
okay, so I've got it downloaded and am running this code: ```py
from pulsectl import Pulse, PulseVolumeInfo
with Pulse('volume-increaser') as pulse:
for sink in pulse.sink_list():
# Volume is usually in 0-1.0 range, with >1.0 being soft-boosted
pulse.volume_change_all_chans(sink, 0.1)```
I'm not exactly sure what I'm doing wrong here, but it is not running
this is the error:
File "/home/braxtenchenay/Programming/Personal/Python/Anti-swear/main.py", line 7, in <module>
pulse.volume_change_all_chans(sink, 0.1)
File "/home/braxtenchenay/.var/app/com.visualstudio.code-oss/data/python/lib/python3.10/site-packages/pulsectl/pulsectl.py", line 805, in volume_change_all_chans
self.volume_set(obj, obj.volume)
File "/home/braxtenchenay/.var/app/com.visualstudio.code-oss/data/python/lib/python3.10/site-packages/pulsectl/pulsectl.py", line 794, in volume_set
method(obj.index, vol)
File "/home/braxtenchenay/.var/app/com.visualstudio.code-oss/data/python/lib/python3.10/site-packages/pulsectl/pulsectl.py", line 631, in _wrapper
with self._pulse_op_cb() as cb:
File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
next(self.gen)
File "/home/braxtenchenay/.var/app/com.visualstudio.code-oss/data/python/lib/python3.10/site-packages/pulsectl/pulsectl.py", line 523, in _pulse_op_cb
if not self._actions[act_id]: raise PulseOperationFailed(act_id)
pulsectl.pulsectl.PulseOperationFailed: 1```
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.