Created
April 16, 2017 18:19
-
-
Save spinscale/fd82f00da29447990f27f36b3f4b927d to your computer and use it in GitHub Desktop.
Hammerspoon: Configure volume via keyboard shortcuts for macbook pro (touchbar, but no keys)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works perfectly on my mechine, macOS 13.3.1, Hammerspoon 0.9.100.