-
-
Save spinscale/fd82f00da29447990f27f36b3f4b927d to your computer and use it in GitHub Desktop.
function changeVolume(diff) | |
return function() | |
local current = hs.audiodevice.defaultOutputDevice():volume() | |
local new = math.min(100, math.max(0, math.floor(current + diff))) | |
if new > 0 then | |
hs.audiodevice.defaultOutputDevice():setMuted(false) | |
end | |
hs.alert.closeAll(0.0) | |
hs.alert.show("Volume " .. new .. "%", {}, 0.5) | |
hs.audiodevice.defaultOutputDevice():setVolume(new) | |
end | |
end | |
hs.hotkey.bind({'ctrl', 'alt', 'cmd'}, 'Down', changeVolume(-3)) | |
hs.hotkey.bind({'ctrl', 'alt', 'cmd'}, 'Up', changeVolume(3)) |
Hi, Alexander:
Not sure if you can see this message, I have tried your lua, it seem only works when I click volume icon on menu bar, if I use those key combination randomly anywhere, it doesn't work.
Have you got this issue?
Thanks,
Kevin
works for me under 10.15.4, with hammerspoon 0.9.78
every volume change also displays a popup for me... can you bind the keys to do sth else just for testing? or play around in the hammerspoon console?
Thanks so much Alexander for getting back to me so quickly.
I am on same mac and hammerspoon versions. very new on lua, not sure how to display debug msg in lua.
The wired part is, if I have click volumn icon on menu bar, volumn list is displayed, your hotkey works properly.
But I am in other application, use the hotkey, will not affect volumn at all
Thanks so much
works perfectly on my mechine, macOS 13.3.1, Hammerspoon 0.9.100.
excellent work, thanks, mate. It works like a charm.