2017-02-02 03:25:25 +01:00
# Volume widget
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
Volume widget based on [amixer ](https://linux.die.net/man/1/amixer ) (is used for controlling the audio volume) and [pacmd ](https://linux.die.net/man/1/pacmd ) (is used for selecting a sink/source). Also, the widget provides an easy way to customize how it looks, following types are supported out-of-the-box:
2017-02-02 03:25:25 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
![types ](screenshots/variations.png )
2017-02-02 03:45:15 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
From left to right: `horizontal_bar` , `vertical_bar` , `icon` , `icon_and_text` , `arc`
2019-09-04 03:57:24 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
A right-click on the widget opens a popup where you can choose a sink/source:
![sink-sources ](screenshots/volume-sink-sources.png )
2019-09-04 03:57:24 +02:00
2021-05-16 00:19:21 +02:00
Left click toggles mute and middle click opens a mixer ([pavucontrol](https://freedesktop.org/software/pulseaudio/pavucontrol/) by default).
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
### Features
2019-09-04 03:57:24 +02:00
2021-12-13 10:36:10 +01:00
- switch between sinks/sources by right click on the widget;
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
- more responsive than previous versions of volume widget, which were refreshed once a second;
- 5 predefined customizable looks;
2017-02-02 03:25:25 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
## Installation
2017-02-02 03:25:25 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
Clone the repo under ** ~/.config/awesome/** and add widget in **rc.lua** :
2017-02-02 03:25:25 +01:00
```lua
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
local volume_widget = require('awesome-wm-widgets.volume-widget.volume')
2017-02-02 03:25:25 +01:00
...
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
-- default
volume_widget(),
-- customized
volume_widget{
2021-04-15 22:29:19 +02:00
widget_type = 'arc'
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
},
2020-02-08 20:39:49 +01:00
```
2023-10-07 22:27:32 +02:00
Note that the widget uses following command to get the current volume: `amixer -c 1 -D pulse sget Master` , so please make sure that it works for you, otherwise you need to set some parameters by entering this command in the terminal:
Command output:
- Some data of a mixer: Override all parameters you've changed
- Error `Invalid card number` : Change parameter `-c` / `card`
- Error `Mixer attach pulse error: No such file or directory` : Change parameter `-D` / `device`
- Error `Unable to find simple control 'Master',0` : Change parameter `mixctrl`
Note: `amixer[ -c ...][ -D ...]` returns a list of Mixers for the selected card/ device. omitting `-D` falls back to `default` .
2021-06-04 02:51:58 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
### Shortcuts
2020-02-08 20:39:49 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
To improve responsiveness of the widget when volume level is changed by a shortcut use corresponding methods of the widget:
2020-02-08 20:39:49 +01:00
```lua
2021-09-23 23:04:26 +02:00
awful.key({ modkey }, "]", function() volume_widget:inc(5) end),
awful.key({ modkey }, "[", function() volume_widget:dec(5) end),
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
awful.key({ modkey }, "\\", function() volume_widget:toggle() end),
2017-02-02 03:25:25 +01:00
```
2017-06-17 18:48:03 +02:00
2023-11-27 15:59:46 +01:00
You also can use Functional keycodes instead of symbols, e.g. `XF86AudioRaiseVolume` instead of `"]"` .
```lua
awful.key({}, "XF86AudioRaiseVolume", function() volume_widget.inc() end),
awful.key({}, "XF86AudioLowerVolume", function() volume_widget.dec() end),
awful.key({}, "XF86AudioMute", function() volume_widget.toggle() end),
```
If you don't know the name of the key, you can use `xev` to find it out.
2023-11-28 08:49:46 +01:00
Or you can use `amixer` and `playerctl` to control the volume and media players.
```lua
awful.key({}, "XF86AudioLowerVolume", function ()
awful.util.spawn("amixer -q -D pulse sset Master 5%-", false) end),
awful.key({}, "XF86AudioRaiseVolume", function ()
awful.util.spawn("amixer -q -D pulse sset Master 5%+", false) end),
awful.key({}, "XF86AudioMute", function ()
awful.util.spawn("amixer -D pulse set Master 1+ toggle", false) end),
-- Media Keys
awful.key({}, "XF86AudioPlay", function()
awful.util.spawn("playerctl play-pause", false) end),
awful.key({}, "XF86AudioNext", function()
awful.util.spawn("playerctl next", false) end),
awful.key({}, "XF86AudioPrev", function()
awful.util.spawn("playerctl previous", false) end),
```
2023-11-27 15:59:46 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
## Customization
2020-02-08 20:39:49 +01:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
It is possible to customize the widget by providing a table with all or some of the following config parameters:
2019-09-18 01:21:34 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
### Generic parameter
2017-02-02 03:25:25 +01:00
2023-10-07 22:27:32 +02:00
| Name | Default | Description |
|---------------|-----------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `mixer_cmd` | `pavucontrol` | command to run on middle click (e.g. a mixer program) |
| `toggle_cmd` | *nil* | Use custom command instead of `amixer ... toggle` because [amixer's unmute option seems to be broken ](https://superuser.com/a/822085 ) |
| `step` | 5 | How much the volume is raised or lowered at once (in %) |
| `widget_type` | `icon_and_text` | Widget type, one of `horizontal_bar` , `vertical_bar` , `icon` , `icon_and_text` , `arc` |
| `card` | 1 | Select the card name to control |
| `device` | `pulse` | Select the device name to control |
| `mixctrl` | `Master` | Select the mixer name to control |
| `value_type` | `-M` | Select how the volume is increased/ decreased (intended for `-M` / `-R` parameters). See `man amixer` for additional info |
2019-08-27 09:20:08 +02:00
2023-10-07 22:47:23 +02:00
Note: If unmuting or toggling using the default amixer command does not work, this command may work: `pactl set-sink-mute [card] toggle`
2021-12-13 10:36:10 +01:00
Depends on the chosen widget type add parameters from the corresponding section below:
2019-08-27 09:20:08 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
#### `icon` parameters
2019-08-27 09:20:08 +02:00
2023-10-07 22:27:32 +02:00
| Name | Default | Description |
|------------|----------------------|-----------------------------------------------|
| `icon_dir` | `[widget_dir]/icons` | Path to the folder with icons (absolute path) |
2019-09-04 03:57:24 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
_Note:_ if you are changing icons, the folder should contain following .svg images:
- audio-volume-high-symbolic
- audio-volume-medium-symbolic
- audio-volume-low-symbolic
- audio-volume-muted-symbolic
2019-08-27 09:20:08 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
#### `icon_and_text` parameters
2019-08-27 09:20:08 +02:00
2023-10-07 22:27:32 +02:00
| Name | Default | Description |
|------------|----------------------|-----------------------------------------------|
| `icon_dir` | `[widget_dir]/icons` | Path to the folder with icons (absolute path) |
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
2019-09-04 03:57:24 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
#### `arc` parameters
2019-08-27 09:20:08 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
| Name | Default | Description |
|---|---|---|
| `thickness` | 2 | Thickness of the arc |
| `main_color` | `beautiful.fg_color` | Color of the arc |
| `bg_color` | `#ffffff11` | Color of the arc's background |
| `mute_color` | `beautiful.fg_urgent` | Color of the arc when mute |
| `size` | 18 | Size of the widget |
2019-09-04 03:57:24 +02:00
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
#### `horizontal_bar` parameters
| Name | Default | Description |
|---|---|---|
| `main_color` | `beautiful.fg_normal` | Color of the bar |
| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute |
2023-09-21 00:01:55 +02:00
| `bg_color` | `#ffffff11` | Color of the bar's background |
| `width` | 50 | The bar width |
| `margins` | 10 | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
| `shape` | `bar` | [gears.shape ](https://awesomewm.org/doc/api/libraries/gears.shape.html ), could be `octogon` , `hexagon` , `powerline` , etc |
| `with_icon` | true | Show volume icon|
[volume] BREAKING CHANGE - new widget instead of old ones
Having three widgets for volume led to a problem of code duplication -
same logic was duplicated three times. However when an issue was
discovered and fixed, it was fixed in only one of three widgets.
So I decided to create a volume widget from scratch, adding new
features, such as selecting input/output, better responsiveness,
easily customizable widget ui (bar, text, icon, icon and text, arc).
Should close #199, #198, #185, #182, #47, #122, #183.
2021-03-20 01:49:00 +01:00
_Note:_ I didn't figure out how does the `forced_height` property of progressbar widget work (maybe it doesn't work at all), thus there is a workaround with margins.
#### `vertical_bar` parameters
| Name | Default | Description |
|---|---|---|
| `main_color` | `beautiful.fg_normal` | Color of the bar |
| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute |
2023-09-21 00:01:55 +02:00
| `bg_color` | `#ffffff11` | Color of the bar's background |
| `width` | 10 | The bar width |
| `margins` | 20 | Top and bottom margins (if your wibar is 22 px high, bar will be 2 px = 22 - 2*10) |
| `shape` | `bar` | [gears.shape ](https://awesomewm.org/doc/api/libraries/gears.shape.html ), could be `octogon` , `hexagon` , `powerline` , etc |
| `with_icon` | true | Show volume icon|