Merge pull request #5 from rsokolkov/master
Added mute detection for volume widget
This commit is contained in:
commit
53e39d21d8
|
@ -21,14 +21,16 @@ volume_widget = wibox.widget {
|
|||
watch(
|
||||
'amixer -D pulse sget Master', 1,
|
||||
function(widget, stdout, stderr, reason, exit_code)
|
||||
local mute = string.match(stdout, "%[(o%D%D?)%]")
|
||||
local volume = string.match(stdout, "(%d?%d?%d)%%")
|
||||
volume = tonumber(string.format("% 3d", volume))
|
||||
local volume_icon_name
|
||||
if (volume >= 0 and volume < 25) then volume_icon_name="audio-volume-muted-symbolic"
|
||||
if mute == "off" then volume_icon_name="audio-volume-muted-symbolic"
|
||||
elseif (volume >= 0 and volume < 25) then volume_icon_name="audio-volume-muted-symbolic"
|
||||
elseif (volume >= 25 and volume < 50) then volume_icon_name="audio-volume-low-symbolic"
|
||||
elseif (volume >= 50 and volume < 75) then volume_icon_name="audio-volume-medium-symbolic"
|
||||
elseif (volume >= 75 and volume <= 100) then volume_icon_name="audio-volume-high-symbolic"
|
||||
end
|
||||
volume_widget.image = path_to_icons .. volume_icon_name .. ".svg"
|
||||
end
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue