summaryrefslogtreecommitdiff
path: root/volume-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2017-01-30 21:38:50 -0500
committerstreetturtle <streetturtle@gmail.com>2017-01-30 21:40:01 -0500
commitc4826fd21340d34e3592b0c8ca24fc068e52c6ef (patch)
treedbbc8fd3df693cfc57cbc1ff5246164f8fc41c01 /volume-widget
parenta079c79ab81a4bc2f7cf7971db6373fefe1e6110 (diff)
new widgets added
Diffstat (limited to 'volume-widget')
-rw-r--r--volume-widget/volume.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
new file mode 100644
index 0000000..3a4793a
--- /dev/null
+++ b/volume-widget/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