summaryrefslogtreecommitdiff
path: root/volume-widget/volume.lua
diff options
context:
space:
mode:
authorPavel Makhov <streetturtle@users.noreply.github.com>2017-02-04 09:45:26 -0500
committerGitHub <noreply@github.com>2017-02-04 09:45:26 -0500
commit53e39d21d86477dd0ec1fbf747c941e928c8b8ff (patch)
tree0fd3c34bef6cae1ac4cf609f285d599bbd6770ae /volume-widget/volume.lua
parentd8328aadc288707c3a3786953a79aa19676ac8bc (diff)
parent5beb57b8e60358934357889d8b579a6d59f0d803 (diff)
Merge pull request #5 from rsokolkov/master
Added mute detection for volume widget
Diffstat (limited to 'volume-widget/volume.lua')
-rw-r--r--volume-widget/volume.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index c403dfd..bdbf134 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -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
-) \ No newline at end of file
+)