-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,16 @@ | |
--- | ||
--- Countdown with visual indicator | ||
--- | ||
--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/CountDown.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/CountDown.spoon.zip) | ||
--- | ||
|
||
local obj = {} | ||
obj.__index = obj | ||
|
||
-- Metadata | ||
obj.name = "CountDown" | ||
obj.version = "2" | ||
obj.author = "ashfinal <[email protected]> and Daniel Marques <[email protected]>" .. | ||
" and Omar El-Domeiri <[email protected]> and Daniel German <[email protected]>" | ||
obj.author = "ashfinal <[email protected]> and Daniel Marques <[email protected]> and Omar El-Domeiri <[email protected]> and Daniel German <[email protected]>" | ||
obj.homepage = "https://github.com/Hammerspoon/Spoons" | ||
obj.license = "MIT - https://opensource.org/licenses/MIT" | ||
|
||
|
@@ -27,12 +28,12 @@ obj.license = "MIT - https://opensource.org/licenses/MIT" | |
|
||
--- CountDown.defaultLenMinutes | ||
--- Variable | ||
--- Default timer in minutes. | ||
--- Default timer in minutes. | ||
obj.defaultLenMinutes = 25 | ||
|
||
--- CountDown.useLastTimerAsDefault | ||
--- Variable | ||
--- if true, make defaultLenMinutes the last time length used | ||
--- if true, make defaultLenMinutes the last time length used | ||
obj.useLastTimerAsDefault = true | ||
|
||
--- CountDown.nofity | ||
|
@@ -42,43 +43,44 @@ obj.notify = true | |
|
||
--- CountDown.defaultKeyBindings | ||
--- Variable | ||
--- default key bindings | ||
--- default key bindings | ||
obj.defaultKeyBindings = { | ||
startFor = {{"cmd", "ctrl", "alt"}, "T"}, | ||
startInteractive = {{"cmd", "ctrl", "alt", "shift"}, "T"}, | ||
pauseOrResume = {{"cmd", "ctrl", "alt"}, "P"}, | ||
cancel = {{"cmd", "ctrl", "alt"}, "C"}, | ||
cancel = {{"cmd", "ctrl", "alt"}, "C"} | ||
} | ||
|
||
--- CountDown.messageDuration | ||
--- Variable | ||
-- Duration of notification messages | ||
--- Duration of notification messages | ||
obj.messageDuration = 2 | ||
|
||
--- CountDown.messageAttributes | ||
--- Variable | ||
-- Properties of progress message | ||
--- Properties of progress message | ||
obj.messageAttributes = {atScreenEdge = 0, textSize = 40} | ||
|
||
-- bar: progress bar at the bottom of the screen | ||
|
||
--- CountDown.barCanvasHeight | ||
--- Variable | ||
--- indicator bar at the bottom of the screen | ||
--- indicator bar at the bottom of the screen | ||
obj.barCanvasHeight = 5 | ||
|
||
--- CountDown.barTransparency | ||
--- Variable | ||
--- Transparency for progress bar | ||
--- Transparency for progress bar | ||
obj.barTransparency = 0.8 | ||
|
||
--- CountDown.barFillColorPassed | ||
--- Variable | ||
--- Color for time passed in progress bar | ||
--- Color for time passed in progress bar | ||
obj.barFillColorPassed = hs.drawing.color.osx_green | ||
|
||
--- CountDown.barFillColorToPass | ||
--- Variable | ||
--- Color for time to pass in progress bar | ||
--- Color for time to pass in progress bar | ||
obj.barFillColorToPass = hs.drawing.color.osx_red | ||
|
||
-- alert: what happens when the timer is up? | ||
|
@@ -148,7 +150,7 @@ obj.menuBarIconPause = "⏸️" | |
--- icon for cancelling timer in menu bar submenu | ||
obj.menuBarIconStop = "🛑" | ||
|
||
-------- state variables | ||
-- state variables | ||
|
||
obj.barTimer= nil | ||
-- timerRunning true if current timer running | ||
|
@@ -172,7 +174,6 @@ obj.menuBar = nil | |
obj.barProgress = 0 | ||
obj.barCanvas = nil | ||
|
||
|
||
-- events | ||
|
||
-- callback when timer is up | ||
|
@@ -504,10 +505,10 @@ function obj:create_tick_timer() | |
1) | ||
end | ||
|
||
- API ------------------------------- | ||
-- API ------------------------------- | ||
|
||
|
||
--- CountDown:startFor(minutes) | ||
--- CountDown:startFor(minutes, callback) | ||
--- Method | ||
--- Start a countdown for `minutes` minutes immediately. Calling this method again will kill the existing countdown instance. | ||
--- | ||
|
@@ -570,7 +571,7 @@ function obj:startFor(minutes, callback) | |
return self | ||
end | ||
|
||
--- CountDown:startUntil(time) | ||
--- CountDown:startUntil(time, callback) | ||
--- Method | ||
--- Start a countdown until time indicated in parameter. | ||
--- | ||
|
@@ -683,6 +684,11 @@ end | |
--- CountDown:cancel() | ||
--- Method | ||
--- Reset the timer | ||
--- | ||
--- Parameters: | ||
--- * None | ||
--- Returns: | ||
--- * None | ||
function obj:cancel() | ||
if obj.timerRunning then | ||
local minLeft = obj.timeLeft/60 | ||
|
@@ -697,7 +703,7 @@ function obj:cancel() | |
end | ||
end | ||
|
||
--- CountDown:bindHotkeys() | ||
--- CountDown:bindHotkeys(mapping) | ||
--- Method | ||
--- Bind hotkeys for this spoon | ||
--- | ||
|