Created
January 25, 2018 17:44
-
-
Save ivanalejandro0/4413d2f813ca9ee700f9e8c77a7b24ba to your computer and use it in GitHub Desktop.
Toggle mic mute on OSX
This file contains hidden or 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
-- Thanks to: | |
-- https://coolaj86.com/articles/how-to-control-os-x-system-volume-with-applescript/ | |
-- https://robservatory.com/silently-mute-the-mic-input-via-applescript/ | |
-- https://macscripter.net/viewtopic.php?id=16588 | |
-- | |
-- For integration with the system see: http://eddmann.com/posts/creating-a-mac-microphone-mute-keyboard-shortcut/ | |
-- | |
-- In order to keep the `storedInputLevel` value you need to use it compiled: | |
-- $ osacompile -o toggle-mic.scpt toggle-mic.applescript | |
-- And then run: | |
-- $ osascript toggle-mic.scpt | |
property storedInputLevel : missing value | |
if input volume of (get volume settings) is 0 then | |
-- we're muted, so it's time to unmute | |
-- get the saved input level, and restore it | |
set volume input volume storedInputLevel | |
else | |
-- we're unmuted, so it's time to mute | |
tell application "System Events" | |
-- save the current input volume setting -- | |
set storedInputLevel to input volume of (get volume settings) | |
end tell | |
-- mute the input | |
set volume input volume 0 | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
input volume of (get volume settings) ,the return value maybe missing value