-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fork MicMute to support my stupid headset with no input mute
- Loading branch information
1 parent
7d4a2db
commit d5f2788
Showing
3 changed files
with
235 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
[ | ||
{ | ||
"Constant" : [ | ||
|
||
], | ||
"submodules" : [ | ||
|
||
], | ||
"Function" : [ | ||
|
||
], | ||
"Variable" : [ | ||
|
||
], | ||
"stripped_doc" : [ | ||
|
||
], | ||
"type" : "Module", | ||
"Deprecated" : [ | ||
|
||
], | ||
"desc" : "Microphone Mute Toggle and status indicator", | ||
"Constructor" : [ | ||
|
||
], | ||
"doc" : "Microphone Mute Toggle and status indicator\n\nDownload: [https:\/\/github.com\/dctucker\/Spoons\/raw\/master\/Spoons\/MicMute.spoon.zip](https:\/\/github.com\/dctucker\/Spoons\/raw\/master\/Spoons\/MicMute.spoon.zip)", | ||
"Method" : [ | ||
{ | ||
"doc" : "Toggle mic mute on\/off", | ||
"stripped_doc" : [ | ||
"Toggle mic mute on\/off" | ||
], | ||
"parameters" : [ | ||
|
||
], | ||
"def" : "MicMute:toggleMicMute()", | ||
"notes" : [ | ||
|
||
], | ||
"signature" : "MicMute:toggleMicMute()", | ||
"type" : "Method", | ||
"returns" : [ | ||
|
||
], | ||
"name" : "toggleMicMute", | ||
"desc" : "Toggle mic mute on\/off" | ||
}, | ||
{ | ||
"doc" : "Binds hotkeys for MicMute\n\nParameters:\n * mapping - A table containing hotkey modifier\/key details for the following items:\n * toggle - This will cause the microphone mute status to be toggled. Hold for momentary, press quickly for toggle.\n * latch_timeout - Time in seconds to hold the hotkey before momentary mode takes over, in which the mute will be toggled again when hotkey is released. Latch if released before this time. 0.75 for 750 milliseconds is a good value.", | ||
"stripped_doc" : [ | ||
"Binds hotkeys for MicMute", | ||
"" | ||
], | ||
"parameters" : [ | ||
" * mapping - A table containing hotkey modifier\/key details for the following items:", | ||
" * toggle - This will cause the microphone mute status to be toggled. Hold for momentary, press quickly for toggle.", | ||
" * latch_timeout - Time in seconds to hold the hotkey before momentary mode takes over, in which the mute will be toggled again when hotkey is released. Latch if released before this time. 0.75 for 750 milliseconds is a good value." | ||
], | ||
"def" : "MicMute:bindHotkeys(mapping, latch_timeout)", | ||
"notes" : [ | ||
|
||
], | ||
"signature" : "MicMute:bindHotkeys(mapping, latch_timeout)", | ||
"type" : "Method", | ||
"returns" : [ | ||
|
||
], | ||
"name" : "bindHotkeys", | ||
"desc" : "Binds hotkeys for MicMute" | ||
} | ||
], | ||
"Command" : [ | ||
|
||
], | ||
"Field" : [ | ||
|
||
], | ||
"items" : [ | ||
{ | ||
"doc" : "Binds hotkeys for MicMute\n\nParameters:\n * mapping - A table containing hotkey modifier\/key details for the following items:\n * toggle - This will cause the microphone mute status to be toggled. Hold for momentary, press quickly for toggle.\n * latch_timeout - Time in seconds to hold the hotkey before momentary mode takes over, in which the mute will be toggled again when hotkey is released. Latch if released before this time. 0.75 for 750 milliseconds is a good value.", | ||
"stripped_doc" : [ | ||
"Binds hotkeys for MicMute", | ||
"" | ||
], | ||
"parameters" : [ | ||
" * mapping - A table containing hotkey modifier\/key details for the following items:", | ||
" * toggle - This will cause the microphone mute status to be toggled. Hold for momentary, press quickly for toggle.", | ||
" * latch_timeout - Time in seconds to hold the hotkey before momentary mode takes over, in which the mute will be toggled again when hotkey is released. Latch if released before this time. 0.75 for 750 milliseconds is a good value." | ||
], | ||
"def" : "MicMute:bindHotkeys(mapping, latch_timeout)", | ||
"notes" : [ | ||
|
||
], | ||
"signature" : "MicMute:bindHotkeys(mapping, latch_timeout)", | ||
"type" : "Method", | ||
"returns" : [ | ||
|
||
], | ||
"name" : "bindHotkeys", | ||
"desc" : "Binds hotkeys for MicMute" | ||
}, | ||
{ | ||
"doc" : "Toggle mic mute on\/off", | ||
"stripped_doc" : [ | ||
"Toggle mic mute on\/off" | ||
], | ||
"parameters" : [ | ||
|
||
], | ||
"def" : "MicMute:toggleMicMute()", | ||
"notes" : [ | ||
|
||
], | ||
"signature" : "MicMute:toggleMicMute()", | ||
"type" : "Method", | ||
"returns" : [ | ||
|
||
], | ||
"name" : "toggleMicMute", | ||
"desc" : "Toggle mic mute on\/off" | ||
} | ||
], | ||
"name" : "MicMute" | ||
} | ||
] |
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,107 @@ | ||
--- === MicMute === | ||
--- | ||
--- Microphone Mute Toggle and status indicator | ||
--- | ||
--- Download: [https://github.com/dctucker/Spoons/raw/master/Spoons/MicMute.spoon.zip](https://github.com/dctucker/Spoons/raw/master/Spoons/MicMute.spoon.zip) | ||
|
||
local obj={} | ||
obj.__index = obj | ||
|
||
-- Metadata | ||
obj.name = "MicMuteFork" | ||
obj.version = "1.0" | ||
obj.author = "dctucker <[email protected]>" | ||
obj.homepage = "https://dctucker.com" | ||
obj.license = "MIT - https://opensource.org/licenses/MIT" | ||
|
||
function obj:updateMicMute() | ||
if hs.audiodevice.defaultInputDevice():inputVolume() <= 1 then | ||
obj.mute_menu:setTitle("📵 Off") | ||
hs.alert('Muted', 1) | ||
else | ||
obj.mute_menu:setTitle("🎙 On") | ||
hs.alert('Unmuted', 1) | ||
end | ||
end | ||
|
||
--- MicMute:toggleMicMute() | ||
--- Method | ||
--- Toggle mic mute on/off | ||
--- | ||
function obj:toggleMicMute() | ||
local mic = hs.audiodevice.defaultInputDevice() | ||
local zoom = hs.application'Zoom' | ||
if mic:inputVolume() == 0 then | ||
mic:setInputVolume(50) | ||
if zoom then | ||
local ok = zoom:selectMenuItem'Unmute Audio' | ||
if not ok then | ||
hs.timer.doAfter(0.5, function() | ||
zoom:selectMenuItem'Unmute Audio' | ||
end) | ||
end | ||
end | ||
else | ||
mic:setInputVolume(0) | ||
if zoom then | ||
local ok = zoom:selectMenuItem'Mute Audio' | ||
if not ok then | ||
hs.timer.doAfter(0.5, function() | ||
zoom:selectMenuItem'Mute Audio' | ||
end) | ||
end | ||
end | ||
end | ||
obj:updateMicMute() | ||
end | ||
|
||
--- MicMute:bindHotkeys(mapping, latch_timeout) | ||
--- Method | ||
--- Binds hotkeys for MicMute | ||
--- | ||
--- Parameters: | ||
--- * mapping - A table containing hotkey modifier/key details for the following items: | ||
--- * toggle - This will cause the microphone mute status to be toggled. Hold for momentary, press quickly for toggle. | ||
--- * latch_timeout - Time in seconds to hold the hotkey before momentary mode takes over, in which the mute will be toggled again when hotkey is released. Latch if released before this time. 0.75 for 750 milliseconds is a good value. | ||
function obj:bindHotkeys(mapping, latch_timeout) | ||
if (self.hotkey) then | ||
self.hotkey:delete() | ||
end | ||
local mods = mapping["toggle"][1] | ||
local key = mapping["toggle"][2] | ||
|
||
if latch_timeout then | ||
self.hotkey = hs.hotkey.bind(mods, key, function() | ||
self:toggleMicMute() | ||
self.time_since_mute = hs.timer.secondsSinceEpoch() | ||
end, function() | ||
if hs.timer.secondsSinceEpoch() > self.time_since_mute + latch_timeout then | ||
self:toggleMicMute() | ||
end | ||
end) | ||
else | ||
self.hotkey = hs.hotkey.bind(mods, key, function() | ||
self:toggleMicMute() | ||
end) | ||
end | ||
|
||
return self | ||
end | ||
|
||
function obj:init() | ||
obj.time_since_mute = 0 | ||
obj.mute_menu = hs.menubar.new() | ||
obj.mute_menu:setClickCallback(function() | ||
obj:toggleMicMute() | ||
end) | ||
obj:updateMicMute() | ||
|
||
hs.audiodevice.watcher.setCallback(function(arg) | ||
if string.find(arg, "dIn ") then | ||
obj:updateMicMute() | ||
end | ||
end) | ||
hs.audiodevice.watcher.start() | ||
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