-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
9,620 additions
and
672 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"Command": [], | ||
"Constant": [], | ||
"Constructor": [], | ||
"Deprecated": [], | ||
"Field": [], | ||
"Function": [], | ||
"Method": [], | ||
"Variable": [], | ||
"desc": "Automatically set to 0 the volume of all output audio devices except Bluetooth devices when Mac goes to sleep.", | ||
"doc": "Automatically set to 0 the volume of all output audio devices except Bluetooth devices when Mac goes to sleep.\nUseful to avoid blasting sound when opening a Macbook in the public transport.\nNote: This is primarily intended for portable Mac devices, which have internal speakers.\n\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip)", | ||
"items": [], | ||
"name": "AutoMuteOnSleep", | ||
"stripped_doc": "Useful to avoid blasting sound when opening a Macbook in the public transport.\nNote: This is primarily intended for portable Mac devices, which have internal speakers.\n\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip)", | ||
"submodules": [], | ||
"type": "Module" | ||
} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- === AutoMuteOnSleep === | ||
--- | ||
--- Automatically set to 0 the volume of all output audio devices except Bluetooth devices when Mac goes to sleep. | ||
--- Useful to avoid blasting sound when opening a Macbook in the public transport. | ||
--- Note: This is primarily intended for portable Mac devices, which have internal speakers. | ||
--- | ||
--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip) | ||
|
||
|
||
local obj={} | ||
obj.__index = obj | ||
|
||
-- Metadata | ||
obj.name = "AutoMuteOnSleep" | ||
obj.version = "1.0" | ||
obj.author = "devnoname120 <[email protected]" | ||
obj.homepage = "https://github.com/Hammerspoon/Spoons" | ||
obj.license = "MIT - https://opensource.org/licenses/MIT" | ||
|
||
obj.sleepWatcher = nil | ||
|
||
local function muteNonBluetoothOutputDevices(state) | ||
if state == hs.caffeinate.watcher.systemDidWake or state == hs.caffeinate.watcher.systemWillSleep then | ||
local devices = hs.audiodevice.allOutputDevices() | ||
|
||
for _, device in ipairs(devices) do | ||
if device and device:transportType() ~= 'Bluetooth' then | ||
_ = device:setVolume(0) or device:setMuted(true) | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
function obj:init() | ||
self.sleepWatcher = hs.caffeinate.watcher.new(muteNonBluetoothOutputDevices) | ||
end | ||
|
||
function obj:start() | ||
self.sleepWatcher:start() | ||
end | ||
|
||
function obj:stop() | ||
self.sleepWatcher:stop() | ||
end | ||
|
||
return obj |
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
Oops, something went wrong.