summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Makhov <pmakhov@touchtunes.com>2018-10-05 11:02:05 -0400
committerPavel Makhov <pmakhov@touchtunes.com>2018-10-05 11:02:05 -0400
commitd185af3b87c17d9afd5602930e3128ba22ab6835 (patch)
tree7cedc9b28540922f98e5bc77b9d4fc8d3598200e
parent60eff0c48fd201e10b0215d897412799d06d97ab (diff)
refactor volume widget
-rw-r--r--volume-widget/volume.lua18
1 files changed, 11 insertions, 7 deletions
diff --git a/volume-widget/volume.lua b/volume-widget/volume.lua
index 31a66e4..8124bcf 100644
--- a/volume-widget/volume.lua
+++ b/volume-widget/volume.lua
@@ -5,7 +5,7 @@
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/volume-widget
-- @author Pavel Makhov
--- @copyright 2017 Pavel Makhov
+-- @copyright 2018 Pavel Makhov
-------------------------------------------------
local awful = require("awful")
@@ -14,7 +14,11 @@ local watch = require("awful.widget.watch")
local spawn = require("awful.spawn")
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
-local request_command = 'amixer -D pulse sget Master'
+
+local GET_VOLUME_CMD = 'amixer -D pulse sget Master'
+local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+'
+local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-'
+local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle'
local volume_widget = wibox.widget {
{
@@ -48,16 +52,16 @@ end
- scrolling when cursor is over the widget
]]
volume_widget:connect_signal("button::press", function(_,_,_,button)
- if (button == 4) then awful.spawn("amixer -D pulse sset Master 5%+", false)
- elseif (button == 5) then awful.spawn("amixer -D pulse sset Master 5%-", false)
- elseif (button == 1) then awful.spawn("amixer -D pulse sset Master toggle", false)
+ if (button == 4) then awful.spawn(INC_VOLUME_CMD, false)
+ elseif (button == 5) then awful.spawn(DEC_VOLUME_CMD, false)
+ elseif (button == 1) then awful.spawn(TOG_VOLUME_CMD, false)
end
- spawn.easy_async(request_command, function(stdout, stderr, exitreason, exitcode)
+ spawn.easy_async(GET_VOLUME_CMD, function(stdout, stderr, exitreason, exitcode)
update_graphic(volume_widget, stdout, stderr, exitreason, exitcode)
end)
end)
-watch(request_command, 1, update_graphic, volume_widget)
+watch(GET_VOLUME_CMD, 1, update_graphic, volume_widget)
return volume_widget \ No newline at end of file