Added volume step

master
Mark 2022-11-05 09:54:25 -07:00
parent bb27fcfaa0
commit e5b253411f
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
5 changed files with 21 additions and 15 deletions

View File

@ -137,9 +137,13 @@ config.mpc = {
config.volume = { config.volume = {
enabled = true, enabled = true,
-- How much % to change volume by
scroll_step = 2,
button_step = 5,
-- The pulse sink volume widgets and keybinds should use. -- The pulse sink volume widgets and keybinds should use.
-- To use the default, keep this value an empty string. -- To use the default, keep this value an empty string.
-- Applies the --sink option to pamixer in wrapper.volume -- Applies the --sink option to pamixer
pamixer_sink = "" pamixer_sink = ""
} }

View File

@ -3,7 +3,7 @@ local volume = req_rel(..., "util")
return gears.table.join( return gears.table.join(
awful.key( {}, "XF86AudioRaiseVolume", awful.key( {}, "XF86AudioRaiseVolume",
function () function ()
volume.volume_up() volume.volume_up(config.volume.button_step)
awesome.emit_signal("module::volume_popup:show") awesome.emit_signal("module::volume_popup:show")
end, end,
{ {
@ -14,7 +14,7 @@ return gears.table.join(
awful.key( {}, "XF86AudioLowerVolume", awful.key( {}, "XF86AudioLowerVolume",
function () function ()
volume.volume_down() volume.volume_down(config.volume.button_step)
awesome.emit_signal("module::volume_popup:show") awesome.emit_signal("module::volume_popup:show")
end, end,
{ {

View File

@ -213,11 +213,11 @@ return function(s)
-- Scroll up -- Scroll up
elseif (button == 4) then elseif (button == 4) then
volume.volume_up() volume.volume_up(config.volume.scroll_step)
-- Scroll down -- Scroll down
elseif (button == 5) then elseif (button == 5) then
volume.volume_down() volume.volume_down(config.volume.scroll_step)
end end
end end
) )

View File

@ -9,9 +9,10 @@ if (config.volume.pamixer_sink ~= "") then
end end
volume.commands = { volume.commands = {
up = function(callback) up = function(value, callback)
awful.spawn.easy_async( awful.spawn.easy_async(
"pamixer --increase 5 " .. volume.pamixer_options, "pamixer --increase " .. value .. " "
.. volume.pamixer_options,
function(stdout, stderr, exitreason, exitcode) function(stdout, stderr, exitreason, exitcode)
awesome.emit_signal("module::volume:update_read") awesome.emit_signal("module::volume:update_read")
if (callback ~= nil) then if (callback ~= nil) then
@ -21,9 +22,10 @@ volume.commands = {
) )
end, end,
down = function(callback) down = function(value, callback)
awful.spawn.easy_async( awful.spawn.easy_async(
"pamixer --decrease 5 " .. volume.pamixer_options, "pamixer --decrease " .. value .. " "
.. volume.pamixer_options,
function(stdout, stderr, exitreason, exitcode) function(stdout, stderr, exitreason, exitcode)
awesome.emit_signal("module::volume:update_read") awesome.emit_signal("module::volume:update_read")
if (callback ~= nil) then if (callback ~= nil) then
@ -116,22 +118,22 @@ awesome.connect_signal("module::volume:update_read",
end end
) )
volume.volume_up = function() volume.volume_up = function(value)
if volume.muted then if volume.muted then
volume.unmute() volume.unmute()
end end
volume.commands.up(function() volume.commands.up(value, function()
core.sound.play("volume_up") core.sound.play("volume_up")
end) end)
end end
volume.volume_down = function() volume.volume_down = function(value)
if volume.muted then if volume.muted then
volume.unmute() volume.unmute()
end end
volume.commands.down(function() volume.commands.down(value, function()
core.sound.play("volume_down") core.sound.play("volume_down")
end) end)
end end

View File

@ -87,11 +87,11 @@ widget.widget:connect_signal("button::press",
-- Scroll up -- Scroll up
elseif (button == 4) then elseif (button == 4) then
volume.volume_up() volume.volume_up(config.volume.scroll_step)
-- Scroll down -- Scroll down
elseif (button == 5) then elseif (button == 5) then
volume.volume_down() volume.volume_down(config.volume.scroll_step)
end end
awesome.emit_signal("module::volume_popup:update") awesome.emit_signal("module::volume_popup:update")
end end