Skip to content

Commit

Permalink
src/lua: keep speaker volume within range when scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
Daru-san committed Oct 31, 2024
1 parent e127fc6 commit 0437b43
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/bar/audio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ return function()
return string.format("%.0f%%", v * 100)
end),
on_scroll = function(_, event)
if event.delta_y < -1 then
speaker.volume = speaker.volume + 0.05
elseif event.delta_y > -1 then
speaker.volume = speaker.volume - 0.05
if speaker.volume <= 1 and speaker.volume >= 0 then
if event.delta_y < -1 then
speaker.volume = speaker.volume + 0.05
elseif event.delta_y > -1 then
speaker.volume = speaker.volume - 0.05
end
elseif speaker.volume > 1 then
speaker.volume = 1
elseif speaker.volume < 0 then
speaker.volume = 0
end
end,
Widget.Box({
Expand Down

0 comments on commit 0437b43

Please sign in to comment.