summaryrefslogtreecommitdiff
path: root/utils.lua
diff options
context:
space:
mode:
Diffstat (limited to 'utils.lua')
-rw-r--r--utils.lua19
1 files changed, 16 insertions, 3 deletions
diff --git a/utils.lua b/utils.lua
index 5a32c55..4e3bb90 100644
--- a/utils.lua
+++ b/utils.lua
@@ -31,9 +31,22 @@ function M.screen_focus_physical(n)
end
-- audio control functions
-function M.vol_control(n)
- local cmd = string.format("amixer -q set Master %d%%", math.abs(n)) .. (n < 0 and "-" or "+")
- awful.spawn(cmd)
+function M.vol_control(wsp, n)
+ local cmd = string.format("amixer set Master %d%%", math.abs(n)) .. (n < 0 and "-" or "+")
+ awful.spawn.easy_async(cmd,
+ function(stdout, stderr, exitreason, exitcode)
+ if exitcode ~= 0 then
+ naughty.notify({ preset = naughty.config.presets.warn,
+ title = "Error changing the audio volume",
+ text = stderr })
+ return
+ end
+
+ local volume = string.match(stdout, '%[(%d+%%)%]')
+ local muted = string.match(stdout, '%[off%]') and ' (Muted)' or ''
+ M.notify_singleton(wsp, 'volume',
+ { title = "Audio volume", text = volume .. muted})
+ end)
end
function M.vol_mute_toggle(wsp)