Skip to content

Commit

Permalink
disable mute shortcut and caffeine toggle for now
Browse files Browse the repository at this point in the history
  • Loading branch information
brettinternet committed Jun 7, 2024
1 parent 29be65d commit df35b88
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 73 deletions.
14 changes: 7 additions & 7 deletions mac/.hammerspoon/audio.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- A better push to talk / toggle mute
local shouldCaffeinate = false
local muteMenu = hs.menubar.new()
-- local muteMenu = hs.menubar.new()

local function setMuteDisplay(mute)
if mute then
muteMenu:setTitle("📵")
else
muteMenu:setTitle("🎤")
end
-- if mute then
-- muteMenu:setTitle("📵")
-- else
-- muteMenu:setTitle("🎤")
-- end
end

local function clearMuteAlert()
Expand Down Expand Up @@ -61,7 +61,7 @@ local function toggleMuteOrPTT()
end
end

hs.hotkey.bind({"cmd", "shift"}, "a", nil, toggleMuteOrPTT, pushToTalk)
-- hs.hotkey.bind({"cmd", "shift"}, "a", nil, toggleMuteOrPTT, pushToTalk)
hs.hotkey.bind(nil, "f18", nil, toggleMute)

if muteMenu then
Expand Down
132 changes: 66 additions & 66 deletions mac/.hammerspoon/system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,69 +19,69 @@ hs.hotkey.bind(nil, "f16", bounceDisplays)

-- Menu bar icon caffeine toggle

local function allowCaffeine()
local noBurnInPls = hs.screen.find("Dell AW3423DW")
return not noBurnInPls
end

local sleepType = "displayIdle"
local isCaffeinate = hs.caffeinate.get(sleepType)
local caffeineMenu = hs.menubar.new()

local function setCaffeineDisplay(keepAwake)
if keepAwake then
caffeineMenu:setTitle("😳")
else
caffeineMenu:setTitle("😴")
end
end

local function setCaffeine(keepAwake)
keepAwake = allowCaffeine() and keepAwake
hs.caffeinate.set(sleepType, keepAwake, true)
setCaffeineDisplay(keepAwake)
end

local function toggleCaffeine()
isCaffeinate = not isCaffeinate
setCaffeine(isCaffeinate)
end

hs.hotkey.bind(nil, "f14", toggleCaffeine)

if caffeineMenu then
caffeineMenu:setClickCallback(toggleCaffeine)
setCaffeine(isCaffeinate)
end

-- Watch screen lock to disable caffeine

local powerWatcher = hs.caffeinate.watcher
local log = hs.logger.new("caffeineMenu", 'verbose')

-- https://github.com/Hammerspoon/hammerspoon/issues/2314#issuecomment-594277092
local function onPower(event)
local name = nil
for key,val in pairs(powerWatcher) do
if event == val then name = key end
end
log.f("caffeinate event %d => %s", event, name)
if event == powerWatcher.screensDidUnlock
or event == powerWatcher.screensaverDidStop
then
log.i("Screen awakened!")
-- Restore Caffeinated state:
setCaffeine(isCaffeinate)
return
end
if event == powerWatcher.screensDidLock
or event == powerWatcher.screensaverDidStart
then
log.i("Screen locked.")
setCaffeine(false)
return
end
end

powerWatcher.new(onPower):start()
log.i("Started.")
-- local function allowCaffeine()
-- local noBurnInPls = hs.screen.find("Dell AW3423DW")
-- return not noBurnInPls
-- end

-- local sleepType = "displayIdle"
-- local isCaffeinate = hs.caffeinate.get(sleepType)
-- local caffeineMenu = hs.menubar.new()

-- local function setCaffeineDisplay(keepAwake)
-- if keepAwake then
-- caffeineMenu:setTitle("😳")
-- else
-- caffeineMenu:setTitle("😴")
-- end
-- end

-- local function setCaffeine(keepAwake)
-- keepAwake = allowCaffeine() and keepAwake
-- hs.caffeinate.set(sleepType, keepAwake, true)
-- setCaffeineDisplay(keepAwake)
-- end

-- local function toggleCaffeine()
-- isCaffeinate = not isCaffeinate
-- setCaffeine(isCaffeinate)
-- end

-- hs.hotkey.bind(nil, "f14", toggleCaffeine)

-- if caffeineMenu then
-- caffeineMenu:setClickCallback(toggleCaffeine)
-- setCaffeine(isCaffeinate)
-- end

-- -- Watch screen lock to disable caffeine

-- local powerWatcher = hs.caffeinate.watcher
-- local log = hs.logger.new("caffeineMenu", 'verbose')

-- -- https://github.com/Hammerspoon/hammerspoon/issues/2314#issuecomment-594277092
-- local function onPower(event)
-- local name = nil
-- for key,val in pairs(powerWatcher) do
-- if event == val then name = key end
-- end
-- log.f("caffeinate event %d => %s", event, name)
-- if event == powerWatcher.screensDidUnlock
-- or event == powerWatcher.screensaverDidStop
-- then
-- log.i("Screen awakened!")
-- -- Restore Caffeinated state:
-- setCaffeine(isCaffeinate)
-- return
-- end
-- if event == powerWatcher.screensDidLock
-- or event == powerWatcher.screensaverDidStart
-- then
-- log.i("Screen locked.")
-- setCaffeine(false)
-- return
-- end
-- end

-- powerWatcher.new(onPower):start()
-- log.i("Started.")

0 comments on commit df35b88

Please sign in to comment.