2020-10-28 14:34:48 +01:00
|
|
|
# Volumectl
|
2021-09-19 15:10:39 +02:00
|
|
|
A small script that bundles volume control and dunst notification. Intended to be used either on command line or for keyboard shortcuts.
|
|
|
|
|
2021-09-19 17:01:06 +02:00
|
|
|
Here below is a demonstration of how it works when pressing the volume and mute
|
|
|
|
keys. The behaviour of the notification is the same if the script was executed
|
|
|
|
from the terminal.
|
2021-09-19 16:30:00 +02:00
|
|
|
![demo](./volumectl_demo.gif)
|
2021-09-19 15:10:39 +02:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
### Dependencies
|
|
|
|
|
|
|
|
#### Dunst
|
2021-09-19 15:11:28 +02:00
|
|
|
Before installing and using this script, you will need to install the official
|
|
|
|
[dunst](https://wiki.archlinux.org/title/Dunst) package.
|
2021-09-19 15:10:39 +02:00
|
|
|
Make sure you have the `dunstify` command available, that's what is needed to
|
2021-09-21 10:34:50 +02:00
|
|
|
have a nice looking percentage bar and make you have this in your `dunstrc` to
|
|
|
|
enable the feature
|
|
|
|
```
|
|
|
|
progressbar = true
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
If you want a similar look as in the gif above, you can just copy the [dunstrc](./dunstrc) in you
|
|
|
|
`$XDG_CONFIG_HOME/dunst/dunstrc` (be sure to **backup** your own `dunstrc`
|
|
|
|
before copying mine).
|
2021-09-19 15:10:39 +02:00
|
|
|
|
|
|
|
#### Bash Ini Reader
|
|
|
|
|
|
|
|
In order to use a custom config file (which is optional, the script works
|
2021-09-19 15:36:53 +02:00
|
|
|
without it but it's useful if you want to customise it), you need to install the
|
|
|
|
[read_ini.sh](https://raw.githubusercontent.com/rudimeier/bash_ini_parser/master/read_ini.sh)
|
2021-09-19 15:37:21 +02:00
|
|
|
script from the [bash_ini_parser](https://github.com/rudimeier/bash_ini_parser)
|
2021-09-19 15:36:53 +02:00
|
|
|
github repo.
|
2021-09-19 15:10:39 +02:00
|
|
|
|
2021-09-19 15:35:26 +02:00
|
|
|
You can do it in two different ways downloading the script directly or cloning
|
|
|
|
the git repo (the script won't care which one you choose, it knows how to handle
|
|
|
|
both situations).
|
2021-09-19 15:10:39 +02:00
|
|
|
|
2021-09-19 16:07:48 +02:00
|
|
|
##### Option 1: Cloning the git repo
|
2021-09-19 15:35:26 +02:00
|
|
|
```bash
|
|
|
|
git clone https://github.com/rudimeier/bash_ini_parser $HOME/.local/lib/bash_ini_parser
|
|
|
|
```
|
|
|
|
|
2021-09-19 16:07:48 +02:00
|
|
|
##### Option 2: Downloading the script directly
|
2021-09-19 16:14:08 +02:00
|
|
|
Make sure you have `wget` installed first.
|
|
|
|
|
|
|
|
Downloading the script directly doesn't change much to do it this way since the
|
|
|
|
repo hasn't been updated in a while.
|
2021-09-19 15:38:47 +02:00
|
|
|
|
2021-09-19 15:10:39 +02:00
|
|
|
```bash
|
|
|
|
mkdir -p $HOME/.local/lib
|
|
|
|
wget -O $HOME/.local/lib/read_ini.sh https://raw.githubusercontent.com/rudimeier/bash_ini_parser/master/read_ini.sh
|
|
|
|
chmod +x $HOME/.local/lib/read_ini.sh
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2021-09-19 15:35:26 +02:00
|
|
|
### Installing volumectl
|
2021-09-19 16:07:48 +02:00
|
|
|
To install this script, you can do it in a similar way as with the ini parser, you
|
|
|
|
can either clone the repo or download the script directly (this option is not recommended
|
|
|
|
because you might miss new features or bug fixes).
|
|
|
|
|
|
|
|
#### Option 1 (recommended): Cloning the repo
|
|
|
|
To make install the script, just clone this repo and then create a symlink to
|
|
|
|
`volumectl` in whatever directory you want (as long as it is in your `$PATH`
|
|
|
|
variable, so that the script will be executable from anywhere in the terminal,
|
|
|
|
see this [link](https://www.tecmint.com/set-path-variable-linux-permanently/)
|
2021-09-19 16:13:07 +02:00
|
|
|
for more info about the `$PATH` variable). In the commands below I'm using the
|
|
|
|
`$HOME/.local/bin`, which by default is **not** in the `$PATH` variable, so make
|
|
|
|
sure you set it.
|
2021-09-19 16:07:48 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
git clone https://github.com/karma-riuk/volumectl $HOME/.local/lib/volumectl
|
2021-09-19 20:17:01 +02:00
|
|
|
mkdir -p $HOME/.local/bin
|
2021-09-19 16:07:48 +02:00
|
|
|
ln -s $HOME/.local/lib/volumectl $HOME/.local/bin/volumectl
|
|
|
|
```
|
|
|
|
|
2021-09-19 16:13:07 +02:00
|
|
|
#### Option 2 (not recommended): Downloading the script directly
|
|
|
|
|
|
|
|
```bash
|
2021-09-19 18:07:24 +02:00
|
|
|
mkdir -p $HOME/.local/bin
|
|
|
|
wget -O $HOME/.local/bin/volumectl https://raw.githubusercontent.com/karma-riuk/volumectl/master/volumectl
|
|
|
|
chmod +x $HOME/.local/bin/volumectl
|
2021-09-19 16:13:07 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2021-09-19 17:01:06 +02:00
|
|
|
## Usage
|
|
|
|
|
2021-09-19 20:06:46 +02:00
|
|
|
### Command line
|
|
|
|
|
2021-09-19 17:01:06 +02:00
|
|
|
To use the script, simply execute the `volumectl` with the flag you want,
|
|
|
|
example:
|
|
|
|
```bash
|
2021-09-19 18:07:24 +02:00
|
|
|
volumectl -i
|
2021-09-19 17:01:06 +02:00
|
|
|
```
|
|
|
|
|
2021-09-19 20:06:46 +02:00
|
|
|
#### Possible flags
|
2021-09-19 17:01:06 +02:00
|
|
|
(You can find all the information below by doing `volumectl -h`)
|
|
|
|
|
2021-09-19 18:12:14 +02:00
|
|
|
|Short flag | Equivalent long flag |Description|
|
|
|
|
|-----|-----|-----|
|
|
|
|
|`-i` | `--increase` | increases the volume by the "normal" amount (by default: 5%) |
|
|
|
|
|`-i <arg>` | `--increase <arg>` | increase the volume by the `<arg>` amount |
|
|
|
|
|`-I` | `--big-increase` | increases the volume by the "big" amount (by default: 10%) |
|
|
|
|
|`-d` | `--decrease` | decreases the volume by the "normal" amount (by default: 5%) |
|
2021-09-19 18:13:09 +02:00
|
|
|
|`-d <arg>` | `--decrease <arg>` | decrease the volume by the `<arg>` amount |
|
2021-09-19 18:12:14 +02:00
|
|
|
|`-D` | `--big-decrease` | decreases the volume by the "big" amount (by default: 10%) |
|
|
|
|
|`-s <arg>` | `--set <arg>` | sets the volume to `<arg>` |
|
|
|
|
|`-m` | `--mute` | activates mute |
|
|
|
|
|`-u` | `--unmute` | deactivates mute |
|
|
|
|
|`-t` | `--toggle` | toggles mute |
|
|
|
|
|`-g` | `--get-volume` | prints the current volume level |
|
|
|
|
|`-G` | `--get-mute` | prints the current mute state |
|
2021-09-19 18:07:24 +02:00
|
|
|
|
|
|
|
|
2021-09-19 20:06:46 +02:00
|
|
|
#### Optional flags
|
2021-09-19 18:13:09 +02:00
|
|
|
|Short flag | Equivalent long flag |Description|
|
|
|
|
|-----|-----|-----|
|
2021-09-19 18:13:55 +02:00
|
|
|
|`-c <file>` | `--config <file>` | use `<file>` as the config file instead of the default location (see below) |
|
2021-09-19 18:13:09 +02:00
|
|
|
|`-v` | `--verbose` | print each step the script passes through |
|
|
|
|
|`-h` | `--help` | print the help message and exit |
|
2021-09-19 17:53:38 +02:00
|
|
|
|
2021-09-19 20:06:46 +02:00
|
|
|
### Key Bindings
|
|
|
|
|
|
|
|
#### Awesomewm
|
|
|
|
Here is an example of how keybindings would look like in awesomewm (tested)
|
|
|
|
|
|
|
|
```lua
|
|
|
|
---- Volume Management
|
|
|
|
awful.key({ }, "XF86AudioMute",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -t")
|
|
|
|
end,
|
|
|
|
{description = "Toggle mute", group = "Media management"}),
|
|
|
|
|
|
|
|
awful.key({ "Shift" }, "XF86AudioMute",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -m")
|
|
|
|
end,
|
|
|
|
{description = "Set mute", group = "Media management"}),
|
|
|
|
|
|
|
|
awful.key({ }, "XF86AudioRaiseVolume",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -i")
|
|
|
|
end,
|
|
|
|
{description = "Increase volume", group = "Media management"}),
|
|
|
|
|
|
|
|
awful.key({ "Shift" }, "XF86AudioRaiseVolume",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -I")
|
|
|
|
end,
|
|
|
|
{description = "Increase volume a lot", group = "Media management"}),
|
|
|
|
|
|
|
|
awful.key({ }, "XF86AudioLowerVolume",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -d")
|
|
|
|
end,
|
|
|
|
{description = "Decrease volume", group = "Media management"}),
|
|
|
|
|
|
|
|
awful.key({ "Shift" }, "XF86AudioLowerVolume",
|
|
|
|
function ()
|
|
|
|
awful.spawn("volumectl -D")
|
|
|
|
end,
|
|
|
|
{description = "Decrease volume a lot", group = "Media management"}),
|
|
|
|
```
|
|
|
|
|
|
|
|
#### i3
|
|
|
|
|
|
|
|
Here is an example of how keybindings would look like in awesomewm (**NOT TESTED**, please tell me if it's wrong)
|
|
|
|
|
|
|
|
```i3
|
|
|
|
bindsym XF86AudioMute exec --no-startup-id volumectl -t
|
|
|
|
bindsym Shift+XF86AudioMute exec --no-startup-id volumectl -m
|
|
|
|
|
|
|
|
bindsym XF86AudioRaiseVolume exec --no-startup-id volumectl -i
|
|
|
|
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id volumectl -I
|
|
|
|
|
|
|
|
bindsym XF86AudioLowerVolume exec --no-startup-id volumectl -d
|
|
|
|
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id volumectl -D
|
|
|
|
```
|
2021-09-19 16:07:48 +02:00
|
|
|
|
2021-09-19 19:35:16 +02:00
|
|
|
## Config
|
|
|
|
|
|
|
|
The config file is an optional feature, but it allows you to set a different
|
2021-09-19 20:16:02 +02:00
|
|
|
volume controller than the default one ([pamixer](https://github.com/cdemoulins/pamixer)).
|
2021-09-19 19:35:16 +02:00
|
|
|
|
2021-09-19 19:44:54 +02:00
|
|
|
To enable the config file, first make you installed the `read_ini.sh` script
|
|
|
|
(see above, in the dependencies) just create a `config.ini` file in the
|
2021-09-19 20:06:46 +02:00
|
|
|
`$XDG_CONFIG_HOME/volumectl` (`$HOME/.config/volumectl/` if `$XDG_CONFIG_HOME`
|
|
|
|
is not set) directory.
|
2021-09-19 19:44:54 +02:00
|
|
|
|
|
|
|
If you think the default values are fine but want to modify just one value,
|
|
|
|
then you can just place that value in the config file, `volumectl` will just
|
|
|
|
take that changed value and keep the rest as default.
|
|
|
|
|
2021-09-19 20:06:46 +02:00
|
|
|
You can see what all the available config variables are by looking at the
|
|
|
|
[example_config.ini](./example_config.ini).
|
|
|
|
|
|
|
|
The easiest way to go to setup a custom config is by running the following commands
|
2021-09-19 20:16:02 +02:00
|
|
|
```bash
|
2021-09-19 20:06:46 +02:00
|
|
|
mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/volumectl
|
|
|
|
cp $HOME/.local/lib/volumectl/example_config.ini ${XDG_CONFIG_HOME:-$HOME/.config}/volumectl/config.ini
|
|
|
|
```
|
|
|
|
and then editing the config with your prefered editor and tinker with it.
|
|
|
|
|
|
|
|
Quick tip: when tinkering with the config, be sure to use `volumectl -v` (it's
|
|
|
|
important to put the `-v` right after the command, so that you see everything
|
|
|
|
that's happening) so that you see what the values are for the variables and
|
|
|
|
will be able to spot where your error is, if there is any.
|
|
|
|
|
|
|
|
|
2021-09-19 19:44:54 +02:00
|
|
|
|
|
|
|
|
2021-09-19 19:35:16 +02:00
|
|
|
|