summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--volume-widget/README.md5
-rw-r--r--volume-widget/volume.lua15
2 files changed, 18 insertions, 2 deletions
diff --git a/volume-widget/README.md b/volume-widget/README.md
index 35d280c..40cc03e 100644
--- a/volume-widget/README.md
+++ b/volume-widget/README.md
@@ -24,9 +24,12 @@ s.mytasklist, -- Middle widget
## Control volume
-To be able to control volume level add following lines in shortcut section of the **rc.lua** (the command could be slightly different depending on your pc configuration):
+To mute/unmute click on widget. To increase/decrease volume scroll up or down when mouse cursor is over the widget.
+
+If you want to control volume level by keyboard shortcuts add following lines in shortcut section of the **rc.lua** (the command could be slightly different depending on your pc configuration):
```lua
awful.key({ modkey}, "[", function () awful.spawn("amixer -D pulse sset Master 5%-") end, {description = "increase volume", group = "custom"}),
awful.key({ modkey}, "]", function () awful.spawn("amixer -D pulse sset Master 5%+") end, {description = "decrease volume", group = "custom"}),
+awful.key({ modkey}, "\\", function () awful.spawn("amixer -D pulse set Master +1 toggle") end, {description = "mute volume", group = "custom"}),
```
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index bdbf134..67ebb78 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -1,7 +1,6 @@
local awful = require("awful")
local wibox = require("wibox")
local watch = require("awful.widget.watch")
-local gears = require("gears")
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
@@ -18,6 +17,20 @@ volume_widget = wibox.widget {
end
}
+--[[ allows control volume level by
+- clicking on the widget to mute/unmute
+- scrolling when curson is over the widget
+]]
+volume_widget:connect_signal("button::press", function(_,_,_,button)
+ if (button == 4) then
+ awful.spawn("amixer -D pulse sset Master 5%+")
+ elseif (button == 5) then
+ awful.spawn("amixer -D pulse sset Master 5%-")
+ elseif (button == 1) then
+ awful.spawn("amixer -D pulse sset Master toggle")
+ end
+end)
+
watch(
'amixer -D pulse sget Master', 1,
function(widget, stdout, stderr, reason, exit_code)