diff --git a/upbeat/README.md b/upbeat/README.md new file mode 100644 index 0000000..5170f0f --- /dev/null +++ b/upbeat/README.md @@ -0,0 +1,5 @@ +

Upbeat

+

widget in action

+
+Upbeat 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. +
diff --git a/upbeat/plugin.toml b/upbeat/plugin.toml new file mode 100644 index 0000000..6963ec7 --- /dev/null +++ b/upbeat/plugin.toml @@ -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" \ No newline at end of file diff --git a/upbeat/thumbnail.webp b/upbeat/thumbnail.webp new file mode 100644 index 0000000..002da1a Binary files /dev/null and b/upbeat/thumbnail.webp differ diff --git a/upbeat/upbeat.luau b/upbeat/upbeat.luau new file mode 100644 index 0000000..8a2c6cc --- /dev/null +++ b/upbeat/upbeat.luau @@ -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 \ No newline at end of file