Skip to content

VolumeScroll: fix broken start() and modernize modifier matching#367

Open
TowyTowy wants to merge 1 commit into
Hammerspoon:masterfrom
TowyTowy:fix/341-volumescroll
Open

VolumeScroll: fix broken start() and modernize modifier matching#367
TowyTowy wants to merge 1 commit into
Hammerspoon:masterfrom
TowyTowy:fix/341-volumescroll

Conversation

@TowyTowy

@TowyTowy TowyTowy commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #341

VolumeScroll errored on start() and its event tap callback threw attempt to call a nil value (method 'sameMods'). The tap callback resolved helper methods through a self that was easily wrong (the documented signature did not show the mods parameter, so dot-calls were common — which also let the tap object be garbage-collected, explaining the "tap eventually stops receiving events" symptom), and the hand-rolled sameMods/tableLength comparison relied on a synthetic scroll event created in :init() just to capture flags.

  • Match modifiers with event:getFlags():containExactly(self.mods), removing sameMods(), tableLength() and the synthetic event in :init()
  • Make :start() work with no arguments (defaults to { "cmd" }) and document the optional mods parameter in the signature, with a colon-call note and usage example
  • Guard against output devices with no volume control and clamp volume to 0..100
  • Make :stop() safe to call before :start()
  • Return self from init/start/stop per SPOONS.md chaining convention

Validated with luac -p, the CI docstring linter (build_docs.py -l), and a mocked-hs logic trace covering both error reproes from the issue.

The spoon errored on start and its event tap callback threw
"attempt to call a nil value (method 'sameMods')" because the tap
callback resolved helper methods through a self that was easily wrong,
and the hand-rolled sameMods/tableLength comparison relied on a
synthetic scroll event created in :init() just to capture flags.

- Match modifiers with event:getFlags():containExactly(self.mods),
  removing sameMods(), tableLength() and the synthetic event in :init()
- Make :start() work with no arguments (defaults to { "cmd" })
  and document the optional mods parameter in the signature
- Guard against devices with no output volume and clamp to 0..100
- Make :stop() safe to call before :start()
- Return self from init/start/stop per SPOONS.md chaining convention

Fixes Hammerspoon#341

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[VolumeScroll] spoon does not work.

1 participant