add lrc plugin (#156)
* added lrc plugin to display lyrics of playing music * added a small demonstration * fixed the readme and added proper thumbnail * added a demo * trimmed up some deps and removed the demo --------- Co-authored-by: shin01221 <mohamed@madin372.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# LRC
|
||||
|
||||

|
||||
|
||||
Displays current song lyrics on the bar widget via `lrc_tty`. Works with MPD and Spotify.
|
||||
|
||||
## Plugin
|
||||
|
||||
| Field | Value |
|
||||
| --- | --- |
|
||||
| ID | `shin/lrc` |
|
||||
| Entries | Bar widget: `lrc` |
|
||||
|
||||
## Requirements
|
||||
|
||||
- `lrc_tty` — fetches synchronized lyrics over the network from the configured provider.
|
||||
- `playerctl` — reads MPRIS player status and metadata.
|
||||
|
||||
## Usage
|
||||
|
||||
Enable `shin/lrc` in Settings → Plugins, then add the **LRC** bar widget. It displays the current lyric line when a track is playing.
|
||||
|
||||
The widget checks MPD first, then falls back to Spotify.
|
||||
|
||||
## Spawned processes
|
||||
|
||||
- `playerctl` — enumerates MPRIS players and queries playback status and metadata.
|
||||
- `lrc_tty` — fetches synchronized lyrics and outputs them.
|
||||
|
||||
## Network access
|
||||
|
||||
`lrc_tty` connects to remote lyric APIs to fetch synchronized lyrics for the currently playing track.
|
||||
@@ -0,0 +1,15 @@
|
||||
id = "shin/lrc"
|
||||
name = "LRC"
|
||||
version = "1.0.0"
|
||||
plugin_api = 3
|
||||
author = "shin"
|
||||
license = "MIT"
|
||||
icon = "music"
|
||||
deprecated = false
|
||||
description = "Displays current song lyrics via lrc_tty."
|
||||
tags = ["bar", "music"]
|
||||
dependencies = ["lrc_tty", "playerctl"]
|
||||
|
||||
[[widget]]
|
||||
id = "lrc"
|
||||
entry = "widget.luau"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,56 @@
|
||||
noctalia.setUpdateInterval(300)
|
||||
|
||||
local fetching = false
|
||||
local mpdPlayer = "mpd"
|
||||
|
||||
noctalia.runAsync("playerctl -l 2>/dev/null", function(r)
|
||||
if r.exitCode == 0 then
|
||||
for name in r.stdout:gmatch("[^\n]+") do
|
||||
if name:match("^mpd%.") then
|
||||
mpdPlayer = name
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function update()
|
||||
if fetching then
|
||||
return
|
||||
end
|
||||
|
||||
if not noctalia.commandExists("lrc_tty") then
|
||||
return
|
||||
end
|
||||
|
||||
noctalia.runAsync("playerctl status --player " .. mpdPlayer .. " 2>/dev/null", function(r)
|
||||
if r.exitCode == 0 and r.stdout:gsub("%s+$", "") == "Playing" then
|
||||
fetchLyrics(mpdPlayer)
|
||||
return
|
||||
end
|
||||
noctalia.runAsync("playerctl status --player spotify 2>/dev/null", function(r2)
|
||||
if r2.exitCode == 0 and r2.stdout:gsub("%s+$", "") == "Playing" then
|
||||
fetchLyrics("spotify")
|
||||
return
|
||||
end
|
||||
barWidget.setText("")
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function fetchLyrics(player)
|
||||
fetching = true
|
||||
|
||||
noctalia.runAsync("lrc_tty --raw --player " .. player, function(r)
|
||||
fetching = false
|
||||
|
||||
if r.exitCode == 0 then
|
||||
local text = r.stdout:gsub("%s+$", "")
|
||||
if #text > 0 and text ~= "(no lyrics)" then
|
||||
barWidget.setText("| " .. text)
|
||||
return
|
||||
end
|
||||
end
|
||||
barWidget.setText("")
|
||||
end,30000)
|
||||
end
|
||||
Reference in New Issue
Block a user