Skip to content

Commit

Permalink
Merge pull request #64 from Aerion/add-microphone
Browse files Browse the repository at this point in the history
Add support for sources (microphone)
  • Loading branch information
marioortizmanero authored Jul 3, 2022
2 parents 166a778 + 330c8d6 commit 399b7e8
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 217 deletions.
116 changes: 74 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

A feature-full volume control module for PulseAudio. Also known as Pavolume. Main features:

* Increase/Decrease and Mute the default sink's audio.
* Switch between sinks easily. You can also blacklist useless devices.
* Increase/Decrease and Mute the default audio node (can be sink or source).
* Switch between nodes easily. You can also blacklist useless devices.
* Optionally enable notifications and OSD messages.
* Works as a shortcut to pavucontrol or your favorite audio manager tool.
* Highly customizable: check the [Usage](#usage) section for details.
Expand Down Expand Up @@ -51,62 +51,74 @@ exec = pulseaudio-control [option...] <action>
where `action`, and (optionally) `option`s are as specified in `pulseaudio-control help`:

```
Usage: pulseaudio-control [OPTION...] ACTION
Usage: ./pulseaudio-control.bash [OPTION...] ACTION
Terminology: A node represents either a sink (output) or source (input).
Options:
--autosync | --no-autosync
Whether to maintain same volume for all programs.
Default: no
Default: "no"
--color-muted <rrggbb>
Color in which to format when muted.
Default: 6b6b6b
Default: "6b6b6b"
--notifications | --no-notifications
Whether to show notifications when changing sinks.
Default: no
Whether to show notifications when changing nodes.
Default: "no"
--osd | --no-osd
Whether to display KDE's OSD message.
Default: no
Default: "no"
--icon-muted <icon>
Icon to use when muted.
Default: none
--icon-sink <icon>
Icon to use for sink.
--icon-node <icon>
Icon to use for node.
Default: none
--format <string>
Use a format string to control the output.
Remember to pass this argument wrapped in single quotes (`'`) instead
of double quotes (`"`) to avoid your shell from evaluating the
variables early.
Available variables:
* $VOL_ICON
* $VOL_LEVEL
* $ICON_SINK
* $SINK_NICKNAME
* $ICON_NODE
* $NODE_NICKNAME
* $IS_MUTED (yes/no)
Default: $VOL_ICON ${VOL_LEVEL}% $ICON_SINK $SINK_NICKNAME
Default: '$VOL_ICON ${VOL_LEVEL}% $ICON_NODE $NODE_NICKNAME'
--icons-volume <icon>[,<icon>...]
Icons for volume, from lower to higher.
Default: none
--node-type <node_type>
Whether to consider PulseAudio sinks (output) or sources (input).
All the operations of pulseaudio-control will apply to one of the two.
Pass `input` for the sources, e.g. a microphone.
Pass `output` for the sinks, e.g. speakers, headphones.
Default: "output"
--volume-max <int>
Maximum volume to which to allow increasing.
Default: 130
Default: "130"
--volume-step <int>
Step size when inc/decrementing volume.
Default: 2
--sink-blacklist <name>[,<name>...]
Sinks to ignore when switching. You can use globs. Don't forget to
Default: "2"
--node-blacklist <name>[,<name>...]
Nodes to ignore when switching. You can use globs. Don't forget to
quote the string when using globs, to avoid unwanted shell glob
extension.
Default: none
--sink-nicknames-from <prop>
pactl property to use for sink names, unless overriden by
--sink-nickname. Its possible values are listed under the 'Properties'
key in the output of `pactl list sinks`
--node-nicknames-from <prop>
pactl property to use for node names, unless overriden by
--node-nickname. Its possible values are listed under the 'Properties'
key in the output of `pactl list sinks` and `pactl list sources`.
Default: none
--sink-nickname <name>:<nick>
Nickname to assign to given sink name, taking priority over
--sink-nicknames-from. May be given multiple times, and 'name' is
exactly as listed in the output of `pactl list sinks short | cut -f2`.
Note that you can also specify a port name for the sink with
--node-nickname <name>:<nick>
Nickname to assign to given node name, taking priority over
--node-nicknames-from. May be given multiple times, and 'name' is
exactly as listed in the output of `pactl list sinks short | cut -f2`
and `pactl list sources short | cut -f2`.
Note that you can also specify a port name for the node with
`<name>/<port>`.
It is also possible to use glob matching to match sink and port names.
It is also possible to use glob matching to match node and port names.
Exact matches are prioritized. Don't forget to quote the string when
using globs, to avoid unwanted shell glob extension.
Default: none
Expand All @@ -116,12 +128,17 @@ Actions:
output print the PulseAudio status once
listen listen for changes in PulseAudio to automatically update
this script's output
up, down increase or decrease the default sink's volume
mute, unmute mute or unmute the default sink's audio
up, down increase or decrease the default node's volume
mute, unmute mute or unmute the default node's audio
togmute switch between muted and unmuted
next-sink switch to the next available sink
next-node switch to the next available node
sync synchronize all the output streams volume to be the same as
the current sink's volume
the current node's volume
Author:
Mario Ortiz Manero
More info on GitHub:
https://github.com/marioortizmanero/polybar-pulseaudio-control
```

See the [Module](#module) section for an example, or the [Useful icons](#useful-icons) section for some packs of icons.
Expand All @@ -137,7 +154,7 @@ The example from the screenshot can:
* Open `pavucontrol` on right click

```ini
[module/pulseaudio-control]
[module/pulseaudio-control-output]
type = custom/script
tail = true
format-underline = ${colors.cyan}
Expand All @@ -147,25 +164,40 @@ label-foreground = ${colors.foreground}
# Icons mixed from Font Awesome 5 and Material Icons
# You can copy-paste your options for each possible action, which is more
# trouble-free but repetitive, or apply only the relevant ones (for example
# --sink-blacklist is only needed for next-sink).
exec = pulseaudio-control --icons-volume " , " --icon-muted "" --sink-nicknames-from "device.description" --sink-nickname "alsa_output.pci-0000_00_1b.0.analog-stereo: Speakers" --sink-nickname "alsa_output.usb-Kingston_HyperX_Virtual_Surround_Sound_00000000-00.analog-stereo: Headphones" listen
# --node-blacklist is only needed for next-node).
exec = pulseaudio-control --icons-volume " , " --icon-muted "" --node-nicknames-from "device.description" --node-nickname "alsa_output.pci-0000_00_1b.0.analog-stereo: Speakers" --node-nickname "alsa_output.usb-Kingston_HyperX_Virtual_Surround_Sound_00000000-00.analog-stereo: Headphones" listen
click-right = exec pavucontrol &
click-left = pulseaudio-control togmute
click-middle = pulseaudio-control --sink-blacklist "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2" next-sink
click-middle = pulseaudio-control --node-blacklist "alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2" next-node
scroll-up = pulseaudio-control --volume-max 130 up
scroll-down = pulseaudio-control --volume-max 130 down

[module/pulseaudio-control-input]
type = custom/script
tail = true
format-underline = ${colors.cyan}
label-padding = 2
label-foreground = ${colors.foreground}

# Use --node-blacklist to remove the unwanted PulseAudio .monitor that are child of sinks
exec = pulseaudio-control --node-type input --icons-volume "" --icon-muted "" --node-nickname "alsa_output.pci-0000_0c_00.3.analog-stereo: Webcam" --node-nickname "alsa_output.usb-Kingston_HyperX_Virtual_Surround_Sound_00000000-00.analog-stereo: Headphones" --node-blacklist "*.monitor" listen
click-right = exec pavucontrol &
click-left = pulseaudio-control --node-type input togmute
click-middle = pulseaudio-control --node-type input next-node
scroll-up = pulseaudio-control --node-type input --volume-max 130 up
scroll-down = pulseaudio-control --node-type input --volume-max 130 down
```

## Useful icons

Here's a list with some icons from different fonts you can copy-paste. Most have an space afterwards so that the module has a bit of spacing. They may appear bugged on your browser if the font isn't available there. Please add yours if they aren't in the list.
Here's a list with some icons from different fonts you can copy-paste. Most have a space afterwards so that the module has a bit of spacing. They may appear bugged on your browser if the font isn't available there. Please add yours if they aren't in the list.

| Font name | Volumes | Muted | Sink icons |
| ----------------------------------------------- | :-------------: | :-----: | :------------------------: |
| [FontAwesome](https://fontawesome.com) | `" , "` | `" "` | `" "` or `" "` |
| [Material](https://material.io/resources/icons) | `" , , "` | `" "` | `" "` or `" "` or `" "` |
| Emoji | `"🔈 ,🔉 ,🔊 "` | `"🔇 "` | `"🔈 "` or `"🎧 "` |
| Emoji v2 | `"🕨 ,🕩 ,🕪 "` | `"🔇 "` | `"🕨 "` or `"🎧 "` |
| Font name | Volumes | Muted | Output icons | Input icons |
| ----------------------------------------------- | :-------------: | :--------------: | :------------------------: | :---------: |
| [FontAwesome](https://fontawesome.com) | `" , , "` | `" "` or `" "` | `" "` or `" "` or `` | `", "` |
| [Material](https://material.io/resources/icons) | `" , , "` | `" "` or `"󰍭 "` | `" "` or `" "` or `" "` | `"󰍬, 󰍮"` |
| Emoji | `"🔈 ,🔉 ,🔊 "` | `"🔇 "` | `"🔈 "` or `"🎧 "` | `"🎙️ "` |
| Emoji v2 | `"🕨 ,🕩 ,🕪 "` | `"🔇 "` | `"🕨 "` or `"🎧 "` | `"🎤 "` |

Most of these can be used after downloading a [Nerd Font](https://www.nerdfonts.com/) and including it in your [Polybar config](https://github.com/polybar/polybar/wiki/Fonts). For example:

Expand Down
Loading

0 comments on commit 399b7e8

Please sign in to comment.