* Add spotify-lyrics plugin * fix(spotify-lyrics): resolve race conditions and add plugin_api * fix(spotify-lyrics): update plugin_api to 3 * fix(spotify-lyrics): resolve github actions validation errors * fix(spotify-lyrics): resize thumbnail to 960x540 to fix validation error * fix(spotify-lyrics): bump version to 1.2.1 * fix(spotify-lyrics): update namespace and replace misleading thumbnail * fix(spotify-lyrics): declare runtime dependencies in plugin.toml and update README requirements * feat(lyrics): implement dynamic panel width sizing * Revert "feat(lyrics): implement dynamic panel width sizing" This reverts commit ef91e6f9f688df7deeb41ba9e5c7606a4904b47a. * feat(spotify-lyrics): implement dynamic panel width sizing * fix(spotify-lyrics): correct target width pre-calculation for upcoming lines * fix(spotify-lyrics): prevent vertical spill by enforcing maxLines=1 * fix(spotify-lyrics): implement dynamic height resizing to encapsulate wrapped text * fix(spotify-lyrics): remove horizontal cap to prevent vertical spill * fix(spotify-lyrics): restore minHeight and implement perfectly safe wrapping height prediction * fix(spotify-lyrics): lock panel width and use vertical dynamic resizing exclusively * fix(spotify-lyrics): implement dynamic font scaling and remove panel dimension animations * fix(spotify-lyrics): restore robust dynamic height logic and discard font scaling * refactor(spotify-lyrics): rewrite height estimation and clean up codebase Root cause: the charUnits per-character width estimation consistently underestimated real rendered widths because the 0.80 multipliers in getLineWidth and getLinesCount cancelled each other out, making the effective calculation ignore the safety margin entirely. Fix: replaced the complex charUnits/toChars/getLineWidth machinery with a simple #text / chars-per-line heuristic using a conservative 0.60x character width factor. This reliably overestimates line count, ensuring the panel always allocates enough height for wrapped text. Quality of life improvements: - Split monolithic render() into renderEmpty/renderPaused/renderPlaying - Reduced update interval from 33ms (30 FPS) to 100ms (10 FPS) - Removed file-read timer (reads every frame at lower FPS instead) - Added clear section headers and inline documentation - Removed all dead code (charUnits, toChars, getLineWidth, etc.) * fix(spotify-lyrics): set panel height=280 in plugin.toml — the actual fix The root cause of the lyrics spilling was never in the Lua code. Noctalia panels are sized exclusively by plugin.toml, not by minHeight on the column layout. Since we had removed width/height from plugin.toml to make sizing 'dynamic', noctalia used a tiny default that couldn't contain wrapped lyrics. minHeight on ui.column had zero effect on the actual panel window size. Set height=280 to comfortably fit 3 lyrics lines even when they wrap. * feat(spotify-lyrics): add dynamic font scaling for long lyrics Long lyrics (>40 chars) now get progressively smaller fonts: - Every 15 chars beyond 40 reduces font by 2px - Minimum font: 10px (panel) / 11px (widget) This prevents vertical overflow regardless of container size by ensuring long lines take up less vertical space when they wrap. * fix(spotify-lyrics): fix plugin IDs and tilde path expansion - Updated bar.luau to toggle correct panel ID - Replaced ~ in noctalia.readFile with absolute path since Lua doesn't auto-expand it - Updated plugin.toml height to 280 and id to noctalia/spotify-lyrics * Fix UI bugs, implement reactive updates, and add album art * Fix plugin manifest validation errors * fix(spotify-lyrics): address PR review comments - Change plugin id from noctalia/ to goatnath/ namespace - Declare runtime dependencies: playerctl, python3, syncedlyrics - Replace hardcoded /home/goatnath path with noctalia.expandPath() - Add [[desktop_widget]] manifest entry for widget.luau - Rewrite README to follow README_TEMPLATE.md structure - Update all references to use corrected plugin id --------- Co-authored-by: goatnath <aadinathkeshav1978@gmail.com>
62 lines
2.1 KiB
Luau
62 lines
2.1 KiB
Luau
--!nonstrict
|
|
-- Minimal bar trigger: shows a small lyrics glyph next to the media widget.
|
|
-- Auto-hides when no music is playing. Click to toggle the lyrics panel.
|
|
--
|
|
-- Also acts as the data bridge: reads the daemon's JSON file and publishes
|
|
-- all lyrics fields into noctalia.state so the panel can reactively consume
|
|
-- them without polling the filesystem itself.
|
|
|
|
local STATE_PATH = noctalia.expandPath("~/.cache/noctalia/lyrics/current.json")
|
|
|
|
local function readState()
|
|
local content = noctalia.readFile(STATE_PATH)
|
|
if not content then return nil end
|
|
local state, _ = noctalia.json.decode(content)
|
|
return state
|
|
end
|
|
|
|
local tickCount = 0
|
|
|
|
function update()
|
|
noctalia.setUpdateInterval(100)
|
|
tickCount = tickCount + 1
|
|
|
|
local state = readState()
|
|
|
|
-- Publish every field the panel/widget needs into noctalia.state.
|
|
-- Each .set() call notifies any panel that called .get() on the same key,
|
|
-- which is what makes the panel re-render reactively.
|
|
if state then
|
|
noctalia.state.set("lyricsStatus", state.status or "")
|
|
noctalia.state.set("lyricsTitle", state.title or "")
|
|
noctalia.state.set("lyricsArtist", state.artist or "")
|
|
noctalia.state.set("lyricsPrevPrev", state.prev_prev or "")
|
|
noctalia.state.set("lyricsPrev", state.prev or "")
|
|
noctalia.state.set("lyricsCurrent", state.current or "")
|
|
noctalia.state.set("lyricsNext", state.next or "")
|
|
noctalia.state.set("lyricsNextNext", state.next_next or "")
|
|
noctalia.state.set("lyricsArtPath", state.art_path or "")
|
|
else
|
|
noctalia.state.set("lyricsStatus", "")
|
|
end
|
|
|
|
-- Bump tick last so the panel can also use it as a generic change signal
|
|
noctalia.state.set("lyricsTick", tickCount)
|
|
|
|
if not state or state.status == "Stopped" or state.status == "" then
|
|
barWidget.setVisible(false)
|
|
return
|
|
end
|
|
|
|
barWidget.setVisible(true)
|
|
barWidget.setGlyph("music")
|
|
barWidget.setText("")
|
|
barWidget.setGlyphColor("primary")
|
|
|
|
barWidget.setTooltip(state.current or "...")
|
|
end
|
|
|
|
function onClick()
|
|
noctalia.togglePanel("goatnath/spotify-lyrics:lyrics-panel")
|
|
end
|