* screen-toolkit: add Noctalia v5 plugin * screen-toolkit: credit original plugin * screen-toolkit: fix recording, OCR capture, and result panel UX * screen-toolkit: rename record tool labels to Record / Rec FS * screen-toolkit: update plugin thumbnail * screen-toolkit: fix README validation (backtick deps, result panel toggle) * screen-toolkit: fix OCR results and dependencies * screen-toolkit: backtick recording and annotator deps in README --------- Co-authored-by: Ahmed5Emad <ahmed5emad@users.noreply.github.com>
67 lines
2.1 KiB
Luau
67 lines
2.1 KiB
Luau
--!nonstrict
|
|
-- Screen Toolkit — bar [[widget]].
|
|
--
|
|
-- Crosshair glyph; a pulsing red dot appears while a recording is active.
|
|
-- Left click toggles the main panel; right click quick-picks a color.
|
|
-- Recording logic lives in the [[service]] — this widget
|
|
-- only reflects the published state and drives the service through the
|
|
-- "command" state channel.
|
|
|
|
local recording = false
|
|
local phase = 0
|
|
local startedAt = nil
|
|
|
|
local function elapsed()
|
|
if not startedAt then return "00:00" end
|
|
local seconds = math.max(0, os.time() - startedAt)
|
|
return string.format("%02d:%02d", math.floor(seconds / 60), seconds % 60)
|
|
end
|
|
|
|
local function render()
|
|
local container = barWidget.isVertical() and ui.column or ui.row
|
|
local children = {}
|
|
if recording then
|
|
table.insert(children, ui.box({
|
|
key = "rec-dot",
|
|
width = 7,
|
|
height = 7,
|
|
radius = 4,
|
|
fill = (phase % 2 == 0) and "error" or "error/0.35",
|
|
}))
|
|
table.insert(children, ui.label({ text = `REC {elapsed()}`, fontSize = 11, fontWeight = "bold", color = "error" }))
|
|
end
|
|
table.insert(children, ui.glyph({ name = "crosshair", size = 14 }))
|
|
barWidget.render(container({ gap = 6, align = "center" }, children))
|
|
barWidget.setTooltip(recording and noctalia.tr("widget.recording") or noctalia.tr("widget.tooltip"))
|
|
end
|
|
|
|
-- Pulse the dot: the bar has no frame ticks, so re-render on a half-second cadence.
|
|
function update()
|
|
noctalia.setUpdateInterval(500)
|
|
phase += 1
|
|
render()
|
|
end
|
|
|
|
noctalia.state.watch("recording", function(value)
|
|
recording = value == true
|
|
startedAt = noctalia.state.get("recordStartedAt")
|
|
render()
|
|
end)
|
|
noctalia.state.watch("recordStartedAt", function(value)
|
|
startedAt = value
|
|
render()
|
|
end)
|
|
|
|
function onClick()
|
|
-- The bar icon never stops a recording; it just opens the panel so the
|
|
-- stop button (in the panel header, next to the close X) is reachable.
|
|
noctalia.togglePanel("alexander/screen-toolkit:panel")
|
|
end
|
|
|
|
function onRightClick()
|
|
-- Quick pick: copies the color and notifies, but never toggles the panel.
|
|
noctalia.state.set("command", { action = "colorPicker", payload = { reopen = false } })
|
|
end
|
|
|
|
render()
|