From 40bd6a775614ee6f3f0017da57ae142d042dfe27 Mon Sep 17 00:00:00 2001 From: Nuno Silva Date: Sat, 15 May 2021 23:19:21 +0100 Subject: volume-widget: open mixer on middle click --- volume-widget/README.md | 3 +++ volume-widget/volume.lua | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/volume-widget/README.md b/volume-widget/README.md index 52e1704..accb731 100644 --- a/volume-widget/README.md +++ b/volume-widget/README.md @@ -9,6 +9,8 @@ From left to right: `horizontal_bar`, `vertical_bar`, `icon`, `icon_and_text`, ` A right-click on the widget opens a popup where you can choose a sink/source: ![sink-sources](screenshots/volume-sink-sources.png) +Left click toggles mute and middle click opens a mixer ([pavucontrol](https://freedesktop.org/software/pulseaudio/pavucontrol/) by default). + ### Features - switch between sinks/sources by right clicking on the widget; @@ -52,6 +54,7 @@ It is possible to customize the widget by providing a table with all or some of | Name | Default | Description | |---|---|---| +| `mixer_cmd` | `pavucontrol` | command to run on middle click (e.g. a mixer program) | | `widget_type`| `icon_and_text`| Widget type, one of `horizontal_bar`, `vertical_bar`, `icon`, `icon_and_text`, `arc` | Depending on the chosen widget type add parameters from the corresponding section below: diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua index 6e99f27..c711950 100644 --- a/volume-widget/volume.lua +++ b/volume-widget/volume.lua @@ -163,6 +163,7 @@ local function worker(user_args) local args = user_args or {} + local mixer_cmd = args.mixer_cmd or 'pavucontrol' local widget_type = args.widget_type local refresh_rate = args.refresh_rate or 1 @@ -194,6 +195,12 @@ local function worker(user_args) spawn.easy_async(TOG_VOLUME_CMD, function(stdout) update_graphic(volume.widget, stdout) end) end + function volume:mixer() + if mixer_cmd then + spawn.easy_async(mixer_cmd) + end + end + volume.widget:buttons( awful.util.table.join( awful.button({}, 3, function() @@ -206,6 +213,7 @@ local function worker(user_args) end), awful.button({}, 4, function() volume:inc() end), awful.button({}, 5, function() volume:dec() end), + awful.button({}, 2, function() volume:mixer() end), awful.button({}, 1, function() volume:toggle() end) ) ) -- cgit v1.2.3