audio output handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{ config, lib, ... }:
|
{ config, lib, pkgs, namespace, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.mjallen.programs.waybar;
|
cfg = config.mjallen.programs.waybar;
|
||||||
@@ -420,12 +420,13 @@ in
|
|||||||
(mkIf cfg.features.audio.sink.enable {
|
(mkIf cfg.features.audio.sink.enable {
|
||||||
"wireplumber#sink" = {
|
"wireplumber#sink" = {
|
||||||
format = "{icon} {volume}%";
|
format = "{icon} {volume}%";
|
||||||
tooltip = false;
|
tooltip-format = "{icon}\n{node_name}\n{format_source}\n{source_desc}";
|
||||||
format-muted = "{icon} Muted";
|
format-muted = "{icon} Muted";
|
||||||
on-click = "wpctl set-mute @DEFAULT_SINK@ toggle";
|
on-click = "wpctl set-mute @DEFAULT_SINK@ toggle";
|
||||||
on-click-right = "pavucontrol -t 1";
|
on-click-right = "pavucontrol -t 1";
|
||||||
on-scroll-up = "wpctl set-volume @DEFAULT_SINK@ 5%+";
|
on-scroll-up = "wpctl set-volume @DEFAULT_SINK@ 5%+";
|
||||||
on-scroll-down = "wpctl set-volume @DEFAULT_SINK@ 5%-";
|
on-scroll-down = "wpctl set-volume @DEFAULT_SINK@ 5%-";
|
||||||
|
on-click-middle = "waybar-audio";
|
||||||
scroll-step = 5;
|
scroll-step = 5;
|
||||||
format-icons = {
|
format-icons = {
|
||||||
headphone = "";
|
headphone = "";
|
||||||
|
|||||||
@@ -6,22 +6,29 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.mjallen.programs.waybar;
|
cfg = config.${namespace}.programs.waybar;
|
||||||
|
|
||||||
pythonEnv = pkgs.python3.withPackages (_ps: [
|
|
||||||
pkgs.${namespace}.pipewire-python
|
|
||||||
]);
|
|
||||||
|
|
||||||
waybar-audio = pkgs.writeScriptBin "waybar-audio" ''
|
waybar-audio = pkgs.writeScriptBin "waybar-audio" ''
|
||||||
#!${pythonEnv}/bin/python
|
#!/usr/bin/env bash
|
||||||
"""run with the special python"""
|
|
||||||
|
|
||||||
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())
|
# Extract ID
|
||||||
print(audio_controller.get_list_targets())
|
id=$(echo "$selected" | awk '{print $1}')
|
||||||
|
|
||||||
|
# Switch to the selected device
|
||||||
|
if [ -n "$id" ]; then
|
||||||
|
wpctl set-default "$id"
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user