diff --git a/modules/home/programs/waybar/default.nix b/modules/home/programs/waybar/default.nix index 3685d94..efeea5d 100755 --- a/modules/home/programs/waybar/default.nix +++ b/modules/home/programs/waybar/default.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, pkgs, namespace, ... }: with lib; let cfg = config.mjallen.programs.waybar; @@ -420,12 +420,13 @@ in (mkIf cfg.features.audio.sink.enable { "wireplumber#sink" = { format = "{icon} {volume}%"; - tooltip = false; + tooltip-format = "{icon}\n{node_name}\n{format_source}\n{source_desc}"; format-muted = "{icon} Muted"; on-click = "wpctl set-mute @DEFAULT_SINK@ toggle"; on-click-right = "pavucontrol -t 1"; on-scroll-up = "wpctl set-volume @DEFAULT_SINK@ 5%+"; on-scroll-down = "wpctl set-volume @DEFAULT_SINK@ 5%-"; + on-click-middle = "waybar-audio"; scroll-step = 5; format-icons = { headphone = "󰋋"; diff --git a/modules/home/programs/waybar/scripts/audio-control.nix b/modules/home/programs/waybar/scripts/audio-control.nix index 5914b7d..4119d61 100644 --- a/modules/home/programs/waybar/scripts/audio-control.nix +++ b/modules/home/programs/waybar/scripts/audio-control.nix @@ -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 {