Skip to content

Commit

Permalink
fix push to talk alert persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
brettinternet committed Mar 19, 2024
1 parent 71d5335 commit a6a1b00
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mac/.hammerspoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,20 @@ end)


-- A better push to talk / toggle mute
function clearMuteAlert()
if muteAlertId then
hs.alert.closeSpecific(muteAlertId)
end
end

local holdingToTalk = false
local function pushToTalk()
holdingToTalk = true
local audio = hs.audiodevice.defaultInputDevice()
local muted = audio:inputMuted()
if muted then
muteAlertId = hs.alert.show("🎤 Microphone on")
clearMuteAlert()
muteAlertId = hs.alert.show("🎤 Microphone on", true)
audio:setInputMuted(false)
end
end
Expand All @@ -125,10 +131,8 @@ local function toggleMuteOrPTT()
muting = true
else
audio:setInputMuted(muting)
if muteAlertId then
hs.alert.closeSpecific(muteAlertId)
end
end
clearMuteAlert()
if muting then
muteAlertId = hs.alert.show("📵 Microphone muted")
else
Expand Down

0 comments on commit a6a1b00

Please sign in to comment.