Skip to content

Commit

Permalink
Redraw window borders only if mouse is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
heussd committed Sep 16, 2024
1 parent 45ce6cf commit e6fcca0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .hammerspoon/focussed-border.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
lastMouseClick = hs.timer.secondsSinceEpoch()
mouseClickListener = hs.eventtap.new({ hs.eventtap.event.types.leftMouseDown }, function(event)
lastMouseClick = hs.timer.secondsSinceEpoch()
end):start()

function redrawBorder()
-- Only redraw border if mouse has not been used for n seconds
if (hs.timer.secondsSinceEpoch() - lastMouseClick < 20) then
return
end

win = hs.window.focusedWindow()
if win ~= nil then
top_left = win:topLeft()
Expand All @@ -7,7 +17,7 @@ function redrawBorder()
global_border:delete()
end
global_border = hs.drawing.rectangle(hs.geometry.rect(top_left['x'], top_left['y'], size['w'], size['h']))
global_border:setStrokeColor({["red"]=1,["blue"]=1,["green"]=0,["alpha"]=0.8})
global_border:setStrokeColor({["red"]=1,["blue"]=1,["green"]=0,["alpha"]=0.5})
global_border:setFill(false)
global_border:setStrokeWidth(20)
global_border:show()
Expand Down

0 comments on commit e6fcca0

Please sign in to comment.