Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chron-isch opened this issue Nov 27, 2020 · 8 comments
Open
Labels
enhancement New feature or request

Comments

@chron-isch
Copy link

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
Copy link

subnut commented Feb 10, 2022

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
Copy link

mknapik commented Mar 24, 2022

@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
Copy link

OJFord commented Apr 9, 2022

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
Copy link

subnut commented Apr 9, 2022

@OJFord You can use

#pulseaudio.input.source-muted {
  background: red;
}

@OJFord
Copy link

OJFord commented Apr 9, 2022

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
Copy link

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
Copy link

ret2src commented Jan 10, 2023

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
Copy link

jistr commented May 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants