audio output handling
This commit is contained in:
@@ -6,22 +6,29 @@
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.mjallen.programs.waybar;
|
||||
|
||||
pythonEnv = pkgs.python3.withPackages (_ps: [
|
||||
pkgs.${namespace}.pipewire-python
|
||||
]);
|
||||
cfg = config.${namespace}.programs.waybar;
|
||||
|
||||
waybar-audio = pkgs.writeScriptBin "waybar-audio" ''
|
||||
#!${pythonEnv}/bin/python
|
||||
"""run with the special python"""
|
||||
#!/usr/bin/env bash
|
||||
|
||||
from pipewire_python.controller import Controller
|
||||
# Extract sink entries: "ID Description"
|
||||
choices=$(pw-dump | jq -r '
|
||||
.. | objects
|
||||
| select(.["media.class"] == "Audio/Sink")
|
||||
| "\(.["object.id"]) \(.["node.description"])"
|
||||
'
|
||||
)
|
||||
|
||||
audio_controller = Controller()
|
||||
# Show wofi menu
|
||||
selected=$(printf "%s\n" "$choices" | wofi --dmenu --prompt "Audio Output")
|
||||
|
||||
print(audio_controller.get_config())
|
||||
print(audio_controller.get_list_targets())
|
||||
# Extract ID
|
||||
id=$(echo "$selected" | awk '{print $1}')
|
||||
|
||||
# Switch to the selected device
|
||||
if [ -n "$id" ]; then
|
||||
wpctl set-default "$id"
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user