make new volume widget more responsive
This commit is contained in:
parent
3cacea5d4e
commit
30738407d8
|
@ -18,9 +18,9 @@ local utils = require("awesome-wm-widgets.experiments.volume.utils")
|
|||
|
||||
local LIST_DEVICES_CMD = [[sh -c "pacmd list-sinks; pacmd list-sources"]]
|
||||
local GET_VOLUME_CMD = 'amixer -D pulse sget Master'
|
||||
local INC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%+'
|
||||
local DEC_VOLUME_CMD = 'amixer -q -D pulse sset Master 5%-'
|
||||
local TOG_VOLUME_CMD = 'amixer -q -D pulse sset Master toggle'
|
||||
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 widget_types = {
|
||||
|
@ -173,22 +173,6 @@ local function worker(user_args)
|
|||
volume_widget = widget_types[widget_type].get_widget(user_args[widget_type .. '_args'])
|
||||
end
|
||||
|
||||
volume_widget:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, 3, function()
|
||||
if popup.visible then
|
||||
popup.visible = not popup.visible
|
||||
else
|
||||
rebuild_popup()
|
||||
popup:move_next_to(mouse.current_widget_geometry)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 4, function() spawn(INC_VOLUME_CMD, false) end),
|
||||
awful.button({}, 5, function() spawn(DEC_VOLUME_CMD, false) end),
|
||||
awful.button({}, 1, function() spawn(TOG_VOLUME_CMD, false) end)
|
||||
)
|
||||
)
|
||||
|
||||
local function update_graphic(widget, stdout)
|
||||
local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
|
||||
if mute == 'off' then widget:mute()
|
||||
|
@ -199,6 +183,28 @@ local function worker(user_args)
|
|||
widget:set_volume_level(volume)
|
||||
end
|
||||
|
||||
volume_widget:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button({}, 3, function()
|
||||
if popup.visible then
|
||||
popup.visible = not popup.visible
|
||||
else
|
||||
rebuild_popup()
|
||||
popup:move_next_to(mouse.current_widget_geometry)
|
||||
end
|
||||
end),
|
||||
awful.button({}, 4, function()
|
||||
spawn.easy_async(INC_VOLUME_CMD, function(stdout) update_graphic(volume_widget, stdout) end)
|
||||
end),
|
||||
awful.button({}, 5, function()
|
||||
spawn.easy_async(DEC_VOLUME_CMD, function(stdout) update_graphic(volume_widget, stdout) end)
|
||||
end),
|
||||
awful.button({}, 1, function()
|
||||
spawn.easy_async(TOG_VOLUME_CMD, function(stdout) update_graphic(volume_widget, stdout) end)
|
||||
end)
|
||||
)
|
||||
)
|
||||
|
||||
watch(GET_VOLUME_CMD, refresh_rate, update_graphic, volume_widget)
|
||||
|
||||
return volume_widget
|
||||
|
|
Loading…
Reference in New Issue