feat: on pi, possibility to change the audio output as well as use bl… #436
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've created the possibility for a pi user, without access to the user interface, to change the oudio output from hdmi, headphone and bluetooth, as well as the possibility to scan and pair to bluetooth devices.
For it to work, it need the PipeWire with Wireplumber
sudo apt install pipewire pipewire-pulse pipewire-jack pipewire-alsa pipewire-audio -y
I created two files in the lib folder
audio_devices.py
andbluetooth.py
.audio devices.py
is the file responsible for getting the possible output audio devices, to connect to them and to increase and decrease their volumes. It useswpctl
from wireplumber.bluetooth.py
is the file that manages bluetooth devices. It can scan for bt devices, connect and remove. It usesbluetoothctl
to do the job. When the script pair to a devices it stores the device in a file calledbtdevices.txt
inside the lib folder. Those are the devices that the system will automatically connect to when it finds it.The user interface to work with these scripts are in the
info.html
.I also created a function inside the
get_platform.py
to check if the pipewire is installed, if not it doesn't run these scripts.One more thing: mainly because of the bluetooth scan, that takes some time, I've made it assyncronous so that the info page loads rigth away while this part is still loading and is updated when finished.