diff --git a/Source/VisualBell.spoon/docs.json b/Source/VisualBell.spoon/docs.json new file mode 100644 index 00000000..955c22c1 --- /dev/null +++ b/Source/VisualBell.spoon/docs.json @@ -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" + } +] diff --git a/Source/VisualBell.spoon/init.lua b/Source/VisualBell.spoon/init.lua new file mode 100644 index 00000000..6f95ef06 --- /dev/null +++ b/Source/VisualBell.spoon/init.lua @@ -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 " +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