Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 160 additions & 0 deletions Source/VisualBell.spoon/docs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
[
{
"Constant" : [

],
"submodules" : [

],
"Function" : [

],
"Variable" : [
{
"name" : "color",
"desc" : "The color of the flash",
"stripped_doc" : [
"The color of the flash"
],
"doc" : "The color of the flash",
"notes" : [

],
"signature" : "VisualBell.color",
"type" : "Variable",
"returns" : [

],
"def" : "VisualBell.color",
"parameters" : [

]
},
{
"name" : "duration",
"desc" : "The duration of the flash",
"stripped_doc" : [
"The duration of the flash"
],
"doc" : "The duration of the flash",
"notes" : [

],
"signature" : "VisualBell.duration",
"type" : "Variable",
"returns" : [

],
"def" : "VisualBell.duration",
"parameters" : [

]
}
],
"stripped_doc" : [

],
"Deprecated" : [

],
"desc" : "Flashes the screen as a visual notification, similar to Vim's 'visualbell'.",
"type" : "Module",
"Constructor" : [

],
"items" : [
{
"name" : "color",
"desc" : "The color of the flash",
"stripped_doc" : [
"The color of the flash"
],
"doc" : "The color of the flash",
"notes" : [

],
"signature" : "VisualBell.color",
"type" : "Variable",
"returns" : [

],
"def" : "VisualBell.color",
"parameters" : [

]
},
{
"name" : "duration",
"desc" : "The duration of the flash",
"stripped_doc" : [
"The duration of the flash"
],
"doc" : "The duration of the flash",
"notes" : [

],
"signature" : "VisualBell.duration",
"type" : "Variable",
"returns" : [

],
"def" : "VisualBell.duration",
"parameters" : [

]
},
{
"name" : "flash",
"desc" : "Flashes the screen using the configured color and duration",
"stripped_doc" : [
"Flashes the screen using the configured color and duration",
""
],
"doc" : "Flashes the screen using the configured color and duration\n\nParameters:\n * None",
"notes" : [

],
"signature" : "VisualBell:flash()",
"type" : "Method",
"returns" : [

],
"def" : "VisualBell:flash()",
"parameters" : [
" * None"
]
}
],
"Method" : [
{
"name" : "flash",
"desc" : "Flashes the screen using the configured color and duration",
"stripped_doc" : [
"Flashes the screen using the configured color and duration",
""
],
"doc" : "Flashes the screen using the configured color and duration\n\nParameters:\n * None",
"notes" : [

],
"signature" : "VisualBell:flash()",
"type" : "Method",
"returns" : [

],
"def" : "VisualBell:flash()",
"parameters" : [
" * None"
]
}
],
"Command" : [

],
"doc" : "Flashes the screen as a visual notification, similar to Vim's 'visualbell'.",
"Field" : [

],
"name" : "VisualBell"
}
]
45 changes: 45 additions & 0 deletions Source/VisualBell.spoon/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- === VisualBell ===
---
--- Flashes the screen as a visual notification, similar to Vim's 'visualbell'.
---
---

local obj = {}
obj.__index = obj

obj.name = "VisualBell"
obj.version = "1.0"
obj.author = "Jon Lorusso <jonlorusso@gmail.com>"
obj.homepage = "https://github.com/Hammerspoon/Spoons"
obj.license = "MIT - https://opensource.org/licenses/MIT"

--- VisualBell.color
--- Variable
--- The color of the flash
obj.color = { white = 1.0, alpha = 0.2 }


--- VisualBell.duration
--- Variable
--- The duration of the flash
obj.duration = 0.15

--- VisualBell:flash()
--- Method
--- Flashes the screen using the configured color and duration
---
--- Parameters:
--- * None
function obj:flash()
local screenFrame = hs.screen.mainScreen():fullFrame()
local flash = hs.drawing.rectangle(screenFrame)

flash:setFillColor(obj.color)
flash:setFill(true)
flash:setLevel(hs.drawing.windowLevels.overlay)
flash:show()

hs.timer.doAfter(obj.duration, function() flash:delete() end)
end

return obj