Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.8k stars 715 forks source link

[Feature Request] - Split pulseaudio module into sink and source modules #925

Open chron-isch opened 4 years ago

chron-isch commented 4 years ago

Hi, most of all, thanks for all the work on waybar.

For most mobile system the way the pulseaudio module currently works is perfectly practical, but as soon as you start using multiple sinks and sources you run into configuration problems. That's why I wanted to ask if it was feasible to split it into separate modules for sink and source and make the actual device it's referring to configurable and just use default/fallback if no device is specified by the user. That way you could also have separate left-, middle-, right-click and on-scroll actions for sinks and sources.

subnut commented 2 years ago

Any progress on this? Currently, there is no way to control the the source (microphone) volume using waybar. Scrolling on any pulseaudio module results in changing the sink (speaker) volume, which is very unintuitive IMO.

mknapik commented 2 years ago

@subnut Controlling source volume works for me when repeating the module twice. volume.sh is a custom script which is a wrapper for pamixer.

{
...
    "pulseaudio#input": {
        "format-source": "",
        "format-source-muted": "",
        "format": "{format_source}",
        "on-click": "volume.sh input-mute",
        "on-scroll-up": "volume.sh input-up",
        "on-scroll-down": "volume.sh input-down",
        "tooltip": false
    },
    "pulseaudio#output": {
        "format": "{volume} {icon}",
        "format-icons": {
            "default": [
                "",
                "",
                "",
                ""
            ]
        },
        "on-click": "volume.sh mute",
        "on-scroll-up": "volume.sh up",
        "on-scroll-down": "volume.sh down",
        "scroll-step": 1,
        "tooltip": false
    },
...
}
OJFord commented 2 years ago

Thanks for that - it's not a complete solution though since both will be styled 'muted' whenever the sink is; ignoring the state of the source.

subnut commented 2 years ago

@OJFord You can use

#pulseaudio.input.source-muted {
  background: red;
}
OJFord commented 2 years ago

Thanks @subnut, (though that should be .input.source-muted if using the names above) ok as a workaround then but I still agree this would be more convenient if they were separate.

abhinandanudupa commented 2 years ago

Thanks @subnut, (though that should be .input.source-muted if using the names above) ok as a workaround then but I still agree this would be more convenient if they were separate.

Does this work now? In my testing it does not.

ret2src commented 1 year ago

Thanks to the comments above, I was able to control the style of the icons for input and output separately. Here's my config:

  "modules-right": [
    "pulseaudio#output",
    "pulseaudio#input",
  ],

  "pulseaudio#input": {
    "format-source": "<span size='large'></span>",
    "format-source-muted": "<span size='large'></span>",
    "format": "{format_source}"
  },

  "pulseaudio#output": {
    "format": "<span size='large'>{icon}</span> {volume}%",
    "format-muted": "<span size='large'> </span>",
    "format-bluetooth": "<span size='large'>{icon}</span> {volume}% <span size='large'>{format_source}</span>",
    "format-icons": {
      "headphone": "",
      "headset": "",
      "phone": "",
      "hdmi": "",
      "default": ["", "", ""]
    },
    "on-click": "$HOME/.config/waybar/scripts/module-actions/pulseaudio click-left",
    "on-click-right": "$HOME/.config/waybar/scripts/module-actions/pulseaudio click-right",
    "on-click-middle": "$HOME/.config/waybar/scripts/module-actions/pulseaudio click-middle",
    "on-scroll-up": "$HOME/.config/waybar/scripts/module-actions/pulseaudio scroll-up",
    "on-scroll-down": "$HOME/.config/waybar/scripts/module-actions/pulseaudio scroll-down",
    "smooth-scrolling-threshold": 5
  },

...and style.css:

#pulseaudio.input.source-muted {
  color: @fg-inactive;
  background: @bg-inactive;
}

#pulseaudio.output.muted {
  color: @fg-inactive;
  background: @bg-inactive;
}
jistr commented 6 months ago

Just adding an alternative solution -- to change the text color based on the muted status of sink/source separately, one can also use Pango markup in the format- strings directly, rather than relying on the CSS muted classes. Here is an expamle:

"pulseaudio": {
    "format": "<span weight=\"bold\">{icon}</span>{volume} {format_source}",
    "format-bluetooth": "<span weight=\"bold\">{icon}</span>{volume} {format_source}",
    "format-bluetooth-muted": "<span color=\"#a89785\"><span weight=\"bold\"></span>{volume}</span> {format_source}",
    "format-muted": "<span color=\"#a89785\"><span weight=\"bold\"></span>{volume}</span> {format_source}",
    "format-source": "<span color=\"#eb4d4b\"><span weight=\"bold\">   </span>{volume}</span>",
    "format-source-muted": "<span color=\"#a89785\"><span weight=\"bold\"></span>{volume}</span>",
    "format-icons": {
        "headphone": "",
        "hands-free": "",
        "headset": "",
        "phone": "",
        "portable": "",
        "car": "",
        "default": ["  ", "  ", ""],
    },
    "on-click": "pavucontrol",
},

Pango markup docs: https://docs.gtk.org/Pango/pango_markup.html