From ccb848c94d41fe71a9a98ad03ae7b393c91b6cfe Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 26 Oct 2021 21:41:20 +0200 Subject: utils: show a notification on mute/unmute --- utils.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'utils.lua') diff --git a/utils.lua b/utils.lua index 5b40dbb..5a32c55 100644 --- a/utils.lua +++ b/utils.lua @@ -36,8 +36,21 @@ function M.vol_control(n) awful.spawn(cmd) end -function M.vol_mute_toggle() - awful.spawn("amixer -q set Master toggle") +function M.vol_mute_toggle(wsp) + local control = 'Master' + awful.spawn.easy_async("amixer sset " .. control .. " toggle", + function(stdout, stderr, exitreason, exitcode) + if exitcode ~= 0 then + naughty.notify({ preset = naughty.config.presets.warn, + title = "Error toggling the " .. control .. " control", + text = stderr }) + return + end + + local text = string.match(stdout, '%[on%]') and 'Unmuted' or 'Muted' + M.notify_singleton(wsp, 'mute', + { title = "Audio", text = text }) + end) end function M.auto_mute_toggle(wsp) -- cgit v1.2.3