forked from ashpie/simple-awesome
Enable support for mute media key
This commit is contained in:
parent
a57fc53a27
commit
64041db6c4
@ -28,11 +28,18 @@ end
|
||||
|
||||
-- Volume control
|
||||
function getVolume()
|
||||
if isMuted() then return 0 end
|
||||
local handle = io.popen("amixer -D pulse sget Master | awk -F\"[][]\" '/%/ { print $2 }' | head -n 1", "r")
|
||||
local volume = string.gsub(handle:read("*a"), "[\n%%]+", "") / 100
|
||||
handle:close()
|
||||
return volume
|
||||
end
|
||||
function isMuted()
|
||||
local handle = io.popen("amixer -D pulse sget Master | awk -F\"[][]\" '/[onf]{2,3}/ { print $4 }' | head -n -1", "r")
|
||||
local muted = string.gsub(handle:read("*a"), "[\n]+", "") == "off"
|
||||
handle:close()
|
||||
return muted
|
||||
end
|
||||
|
||||
function getVolumeImage(volume)
|
||||
local path = beautiful.volume_osd_icon_3
|
||||
@ -161,6 +168,11 @@ local lowerVolume = function()
|
||||
os.execute("amixer -D pulse set Master 5%-")
|
||||
displayVolume()
|
||||
end
|
||||
local toggleMute = function()
|
||||
local muted = isMuted()
|
||||
os.execute("amixer -D pulse set Master " .. (muted and 'on' or 'off'))
|
||||
displayVolume()
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return {
|
||||
@ -168,5 +180,6 @@ return {
|
||||
nextTrack = nextTrack,
|
||||
previousTrack = previousTrack,
|
||||
raiseVolume = raiseVolume,
|
||||
lowerVolume = lowerVolume
|
||||
lowerVolume = lowerVolume,
|
||||
toggleMute = toggleMute
|
||||
}
|
4
rc.lua
4
rc.lua
@ -441,7 +441,9 @@ globalkeys = gears.table.join(
|
||||
awful.key({}, "XF86AudioRaiseVolume", media_control.raiseVolume,
|
||||
{description = "Raise volume", group="media control"}),
|
||||
awful.key({}, "XF86AudioLowerVolume", media_control.lowerVolume,
|
||||
{description = "Lower volume", group="media control"})
|
||||
{description = "Lower volume", group="media control"}),
|
||||
awful.key({}, "XF86AudioMute", media_control.toggleMute,
|
||||
{description = "Toggle mute audio", group="media control"})
|
||||
)
|
||||
|
||||
clientkeys = gears.table.join(
|
||||
|
Loading…
Reference in New Issue
Block a user