feat(upbeat): add plugin directory for Upbeat
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<h1>Upbeat</h1>
|
||||
<p align="center"><img src="thumbnail.webp" alt="widget in action"></p>
|
||||
<br>
|
||||
<strong>Upbeat</strong> is a bar widget plugin written for Noctalia (v5) that displays the current Internet Time. Internet time is a subversive, yet extremely accurate and location agnostic way of telling time created in the 90s for the purpose of communicating in the future. Also it's kinda funny.
|
||||
<br>
|
||||
@@ -0,0 +1,35 @@
|
||||
id = "neuro/upbeat"
|
||||
name = "Upbeat"
|
||||
version = "1.0.0"
|
||||
min_noctalia = "5.0.0"
|
||||
author = "neuro"
|
||||
license = "MIT"
|
||||
icon = "at"
|
||||
deprecated = false
|
||||
description = "A bar widget that displays Swatch Internet (.beat) Time"
|
||||
tags = ["fun", "clock", "utility", "time"]
|
||||
|
||||
[[widget]]
|
||||
id = "upbeat"
|
||||
entry = "upbeat.luau"
|
||||
|
||||
[[widget.setting]]
|
||||
key = "show_centibeats"
|
||||
type = "bool"
|
||||
label = "Display subbeats"
|
||||
default = true
|
||||
description = "Toggle subbeat display (.xx)"
|
||||
|
||||
[[widget.setting]]
|
||||
key = "beat_display"
|
||||
type = "bool"
|
||||
label = "Display .beats"
|
||||
default = false
|
||||
description = "Toggle internet time notation (.beats)"
|
||||
|
||||
[[widget.setting]]
|
||||
key = "time_format_toggle"
|
||||
type = "bool"
|
||||
label = "Toggle 24Hr time"
|
||||
default = false
|
||||
description = "Display 24 hour time"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
@@ -0,0 +1,45 @@
|
||||
--!nonstrict
|
||||
local BIEL_OFFSET_SECONDS: number = 3600 -- UTC +1
|
||||
local SECONDS_PER_CENTIBEAT: number = 0.864
|
||||
local lastValue: number = -1
|
||||
|
||||
-- definitions for converting local time to .beat time
|
||||
-- seconds per day 86400
|
||||
-- seconds per beat 86.4
|
||||
-- seconds per centibeat 0.864
|
||||
|
||||
function update()
|
||||
barWidget.setGlyph("at")
|
||||
local secondsSinceMidnight: number = (os.time() + BIEL_OFFSET_SECONDS) % 86400 -- 86400 = seconds in one day
|
||||
local totalCentibeats: number = math.floor(secondsSinceMidnight / SECONDS_PER_CENTIBEAT)
|
||||
-- define display of subbeat toggle
|
||||
local useCentibeats: boolean = barWidget.getConfig("show_centibeats")
|
||||
-- define display of @beats toggle
|
||||
local showSuffix: boolean = barWidget.getConfig("beat_display")
|
||||
local timeFormatToggle: boolean = barWidget.getConfig("time_format_toggle")
|
||||
local checkValue: number = useCentibeats and totalCentibeats or math.floor(totalCentibeats / 100)
|
||||
-- layout updates when values tick
|
||||
if checkValue ~= lastValue then
|
||||
lastValue = checkValue
|
||||
-- display .beat suffix toggle
|
||||
local suffix: string = showSuffix and " .beats" or ""
|
||||
if useCentibeats then
|
||||
barWidget.setText(string.format("%03d.%02d", math.floor(totalCentibeats / 100), totalCentibeats % 100) .. suffix)
|
||||
else
|
||||
barWidget.setText(string.format("%03d", checkValue) .. suffix)
|
||||
end
|
||||
end
|
||||
-- define display of 24h time toggle
|
||||
local tooltipFormat: string = timeFormatToggle and "%T" or "%I:%M %p"
|
||||
-- on hover displays the user's "real" time
|
||||
barWidget.setTooltip(noctalia.formatTime(tooltipFormat))
|
||||
-- resource savings when subbeats not shown
|
||||
if useCentibeats then
|
||||
noctalia.setUpdateInterval(200) -- high tick when tracking subbeats
|
||||
else
|
||||
-- return remaining seconds until whole beat
|
||||
local secondsToNextBeat: number = 86.4 - (secondsSinceMidnight % 86.4)
|
||||
-- defines targeting of next whole beat change (+100ms padding)
|
||||
noctalia.setUpdateInterval(math.floor((secondsToNextBeat * 1000) + 100))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user