From 2d2684587d61b294ef1f0c7f1a1d251a0aaf884a Mon Sep 17 00:00:00 2001 From: Pavel Makhov Date: Mon, 23 Jan 2017 11:01:16 -0500 Subject: Move v4 compatible widget in this repo --- volume-widget-v4/volume.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 volume-widget-v4/volume.lua (limited to 'volume-widget-v4') diff --git a/volume-widget-v4/volume.lua b/volume-widget-v4/volume.lua new file mode 100644 index 0000000..3a4793a --- /dev/null +++ b/volume-widget-v4/volume.lua @@ -0,0 +1,26 @@ +local wibox = require("wibox") +local awful = require("awful") + +function update_volume() + awful.spawn.easy_async([[bash -c 'amixer -D pulse sget Master']], + function(stdout, stderr, reason, exit_code) + local volume = string.match(stdout, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + local volume_icon_name + + if (volume >= 0 and volume < 20) then volume_icon_name="audio-volume-none-panel" + elseif (volume >= 20 and volume < 40) then volume_icon_name="audio-volume-zero-panel" + elseif (volume >= 40 and volume < 60) then volume_icon_name="audio-volume-low-panel" + elseif (volume >= 60 and volume < 80) then volume_icon_name="audio-volume-medium-panel" + elseif (volume >= 80 and volume <= 100) then volume_icon_name="audio-volume-high-panel" + end + volume_icon:set_image("/usr/share/icons/Arc-Icons/panel/22/" .. volume_icon_name .. ".svg") + end) +end + + +volume_icon = wibox.widget.imagebox() + +mytimer = timer({ timeout = 0.2 }) +mytimer:connect_signal("timeout", function () update_volume() end) +mytimer:start() \ No newline at end of file -- cgit v1.2.3