4 ms·
I use hammerspoon (https://www.hammerspoon.org/ https://www.hammerspoon.org/) and have a section in my ~/.hammerspoon/init.lua that puts things into "focus mode
by seanhunter 5y ago
I use hammerspoon (https://www.hammerspoon.org/ https://www.hammerspoon.org/) and have a section in my ~/.hammerspoon/init.lua that puts things into "focus mode" where it centers my current focussed window and minimizes everything else. If I used notifications (I turn them all off all the time) I would put it into do not disurb mode during this time also. Here's a snippet that does this:
focusTimer = nil -- A timer for when we are in "Focus Mode"
function focusModeOff()
all = hs.window.allWindows()
for _, w in pairs(all) do
if(w:isMinimized()) then
w:unminimize()
end
end
applyStandardLayout()
if(focusTimer ~= nil) then
focusTimer:stop()
focusTimer = nil
end
end
-- Focus mode
function focusMode()
if(focusTimer == nil) then
hs.alert("Setting focus for 25mins.")
local focused = hs.window.focusedWindow()
if(focused ~= nil) then
focused:centerOnScreen()
end
all = hs.window.allWindows()
for _, w in pairs(all) do
if(focused ~= nil and w:id() ~= focused:id()) then
w:minimize()
end
end
focusTimer = hs.timer.doAfter(25 * 60, function()
focusModeOff()
hs.alert("Take a 5min break. Record what you just did.")
--TODO: Make a pomodoro recording thing
end)
else
local remaining = focusTimer:nextTrigger()
local remainingSec = math.floor(remaining % 60)
local remainingMin = math.floor(remaining / 60)
hs.alert("Focus timer expires in " .. remainingMin .. "m " .. remainingSec .. "s.")
end
end
--focus mode
hs.hotkey.bind({"cmd", "ctrl"}, "Return", focusMode)