lrc: add settings panel for separator (#172)

* added a basic settings panel

* fix lrc settings: nest translation keys and document settings in README

---------

Co-authored-by: shin01221 <mohamed@madin372.com>
This commit is contained in:
shin01221
2026-07-31 08:17:56 -04:00
committed by GitHub
co-authored by shin01221
parent c861c17e02
commit f9dc0d4a03
4 changed files with 41 additions and 3 deletions
+7
View File
@@ -22,6 +22,13 @@ Enable `shin/lrc` in Settings → Plugins, then add the **LRC** bar widget. It d
The widget checks MPD first, then falls back to Spotify. The widget checks MPD first, then falls back to Spotify.
## Settings
| Key | Type | Default | Description |
| --- | --- | --- | --- |
| `show_separator` | bool | `true` | Prepend a separator before the lyric text. |
| `separator` | string | `"\| "` | Text shown before the current lyric line. |
## Spawned processes ## Spawned processes
- `playerctl` — enumerates MPRIS players and queries playback status and metadata. - `playerctl` — enumerates MPRIS players and queries playback status and metadata.
+15 -1
View File
@@ -1,6 +1,6 @@
id = "shin/lrc" id = "shin/lrc"
name = "LRC" name = "LRC"
version = "1.0.0" version = "1.1.0"
plugin_api = 3 plugin_api = 3
author = "shin" author = "shin"
license = "MIT" license = "MIT"
@@ -10,6 +10,20 @@ description = "Displays current song lyrics via lrc_tty."
tags = ["bar", "music"] tags = ["bar", "music"]
dependencies = ["lrc_tty", "playerctl"] dependencies = ["lrc_tty", "playerctl"]
[[setting]]
key = "show_separator"
type = "bool"
label_key = "settings.show_separator.label"
description_key = "settings.show_separator.description"
default = true
[[setting]]
key = "separator"
type = "string"
label_key = "settings.separator.label"
description_key = "settings.separator.description"
default = "| "
[[widget]] [[widget]]
id = "lrc" id = "lrc"
entry = "widget.luau" entry = "widget.luau"
+12 -1
View File
@@ -1 +1,12 @@
{} {
"settings": {
"show_separator": {
"label": "Show separator",
"description": "Prepend a separator before the lyric text."
},
"separator": {
"label": "Separator",
"description": "Text shown before the current lyric line."
}
}
}
+7 -1
View File
@@ -2,6 +2,8 @@ noctalia.setUpdateInterval(300)
local fetching = false local fetching = false
local mpdPlayer = "mpd" local mpdPlayer = "mpd"
local showSeparator = noctalia.getConfig("show_separator") ~= false
local separator = noctalia.getConfig("separator") or "| "
noctalia.runAsync("playerctl -l 2>/dev/null", function(r) noctalia.runAsync("playerctl -l 2>/dev/null", function(r)
if r.exitCode == 0 then if r.exitCode == 0 then
@@ -47,7 +49,11 @@ function fetchLyrics(player)
if r.exitCode == 0 then if r.exitCode == 0 then
local text = r.stdout:gsub("%s+$", "") local text = r.stdout:gsub("%s+$", "")
if #text > 0 and text ~= "(no lyrics)" then if #text > 0 and text ~= "(no lyrics)" then
barWidget.setText("| " .. text) local prefix = ""
if showSeparator then
prefix = separator
end
barWidget.setText(prefix .. text)
return return
end end
end end