diff options
author | streetturtle <streetturtle@gmail.com> | 2015-07-13 22:56:52 +0200 |
---|---|---|
committer | streetturtle <streetturtle@gmail.com> | 2015-07-13 22:56:52 +0200 |
commit | 5d3e23efe20ef50f4d6721ef9473fc311d5d21a3 (patch) | |
tree | ce632e6fb6c396ab89712822855222816496a07b | |
parent | d79cc9727a5f0a0f9ce3f56c26d0175181ad1c28 (diff) |
Volume widget
-rw-r--r-- | VolumeWidget/volume-icons/1.png | bin | 0 -> 233 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/2.png | bin | 0 -> 242 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/3.png | bin | 0 -> 248 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/4.png | bin | 0 -> 255 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/5.png | bin | 0 -> 260 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/6.png | bin | 0 -> 270 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/7.png | bin | 0 -> 273 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/8.png | bin | 0 -> 282 bytes | |||
-rw-r--r-- | VolumeWidget/volume-icons/9.png | bin | 0 -> 286 bytes | |||
-rw-r--r-- | VolumeWidget/volume.lua | 35 |
10 files changed, 35 insertions, 0 deletions
diff --git a/VolumeWidget/volume-icons/1.png b/VolumeWidget/volume-icons/1.png Binary files differnew file mode 100644 index 0000000..3f4e6b4 --- /dev/null +++ b/VolumeWidget/volume-icons/1.png diff --git a/VolumeWidget/volume-icons/2.png b/VolumeWidget/volume-icons/2.png Binary files differnew file mode 100644 index 0000000..9a488c7 --- /dev/null +++ b/VolumeWidget/volume-icons/2.png diff --git a/VolumeWidget/volume-icons/3.png b/VolumeWidget/volume-icons/3.png Binary files differnew file mode 100644 index 0000000..a1bfb30 --- /dev/null +++ b/VolumeWidget/volume-icons/3.png diff --git a/VolumeWidget/volume-icons/4.png b/VolumeWidget/volume-icons/4.png Binary files differnew file mode 100644 index 0000000..8f11110 --- /dev/null +++ b/VolumeWidget/volume-icons/4.png diff --git a/VolumeWidget/volume-icons/5.png b/VolumeWidget/volume-icons/5.png Binary files differnew file mode 100644 index 0000000..613cb4a --- /dev/null +++ b/VolumeWidget/volume-icons/5.png diff --git a/VolumeWidget/volume-icons/6.png b/VolumeWidget/volume-icons/6.png Binary files differnew file mode 100644 index 0000000..1defc8a --- /dev/null +++ b/VolumeWidget/volume-icons/6.png diff --git a/VolumeWidget/volume-icons/7.png b/VolumeWidget/volume-icons/7.png Binary files differnew file mode 100644 index 0000000..8207899 --- /dev/null +++ b/VolumeWidget/volume-icons/7.png diff --git a/VolumeWidget/volume-icons/8.png b/VolumeWidget/volume-icons/8.png Binary files differnew file mode 100644 index 0000000..423f213 --- /dev/null +++ b/VolumeWidget/volume-icons/8.png diff --git a/VolumeWidget/volume-icons/9.png b/VolumeWidget/volume-icons/9.png Binary files differnew file mode 100644 index 0000000..e7c40df --- /dev/null +++ b/VolumeWidget/volume-icons/9.png diff --git a/VolumeWidget/volume.lua b/VolumeWidget/volume.lua new file mode 100644 index 0000000..e800c32 --- /dev/null +++ b/VolumeWidget/volume.lua @@ -0,0 +1,35 @@ +local wibox = require("wibox") +local awful = require("awful") + +volume_widget = wibox.widget.textbox() +volume_icon = wibox.widget.imagebox() + +function update_volume(widget, icon) + local fd = io.popen("amixer -D pulse sget Master") + local status = fd:read("*all") + fd:close() + + local volume = string.match(status, "(%d?%d?%d)%%") + volume = tonumber(string.format("% 3d", volume)) + + status = string.match(status, "%[(o[^%]]*)%]") + + if (volume >= 0 and volume < 10) then volumeLevel=1 + elseif (volume >= 10 and volume < 20) then volumeLevel=2 + elseif (volume >= 20 and volume < 30) then volumeLevel=3 + elseif (volume >= 30 and volume < 40) then volumeLevel=4 + elseif (volume >= 40 and volume < 50) then volumeLevel=5 + elseif (volume >= 50 and volume < 60) then volumeLevel=6 + elseif (volume >= 60 and volume < 70) then volumeLevel=7 + elseif (volume >= 70 and volume < 80) then volumeLevel=8 + elseif (volume >= 80 and volume <= 100) then volumeLevel=9 + end + + icon:set_image("/home/pashik/.config/awesome/volume-icons/" .. volumeLevel .. ".png") +end + +update_volume(volume_widget, volume_icon) + +mytimer = timer({ timeout = 0.2 }) +mytimer:connect_signal("timeout", function () update_volume(volume_widget, volume_icon) end) +mytimer:start()
\ No newline at end of file |