chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
-- auto-eq.lua — Automatically switch EQ preset based on track genre.
|
||||
|
||||
local p = plugin.register({
|
||||
name = "auto-eq",
|
||||
type = "hook",
|
||||
version = "1.0.0",
|
||||
description = "Switch EQ based on track genre",
|
||||
permissions = {"control"},
|
||||
})
|
||||
|
||||
-- Map genres to EQ presets. Keys are lowercase for case-insensitive matching.
|
||||
local genre_map = {
|
||||
rock = "Rock",
|
||||
["alt-rock"] = "Rock",
|
||||
["hard rock"] = "Rock",
|
||||
metal = "Rock",
|
||||
punk = "Rock",
|
||||
grunge = "Rock",
|
||||
pop = "Pop",
|
||||
["synth-pop"] = "Pop",
|
||||
jazz = "Jazz",
|
||||
["smooth jazz"] = "Jazz",
|
||||
bossa = "Jazz",
|
||||
classical = "Classical",
|
||||
orchestra = "Classical",
|
||||
electronic = "Electronic",
|
||||
edm = "Electronic",
|
||||
techno = "Electronic",
|
||||
house = "Electronic",
|
||||
trance = "Electronic",
|
||||
ambient = "Electronic",
|
||||
["hip-hop"] = "Hip-Hop",
|
||||
["hip hop"] = "Hip-Hop",
|
||||
rap = "Hip-Hop",
|
||||
trap = "Hip-Hop",
|
||||
["r&b"] = "R&B",
|
||||
rnb = "R&B",
|
||||
soul = "R&B",
|
||||
folk = "Acoustic",
|
||||
acoustic = "Acoustic",
|
||||
["singer-songwriter"] = "Acoustic",
|
||||
country = "Acoustic",
|
||||
podcast = "Podcast",
|
||||
speech = "Podcast",
|
||||
lofi = "Late Night",
|
||||
["lo-fi"] = "Late Night",
|
||||
chill = "Late Night",
|
||||
}
|
||||
|
||||
local last_preset = nil
|
||||
|
||||
p:on("track.change", function(track)
|
||||
local genre = (track.genre or ""):lower()
|
||||
local preset = genre_map[genre]
|
||||
|
||||
if not preset then
|
||||
-- Try partial match for compound genres like "Indie Rock".
|
||||
for key, val in pairs(genre_map) do
|
||||
if genre:find(key, 1, true) then
|
||||
preset = val
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
preset = preset or "Flat"
|
||||
|
||||
if preset ~= last_preset then
|
||||
cliamp.player.set_eq_preset(preset)
|
||||
last_preset = preset
|
||||
cliamp.log.info("EQ -> " .. preset .. " (genre: " .. (track.genre or "unknown") .. ")")
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,40 @@
|
||||
-- now-playing.lua — Write current track to /tmp for status bars (Waybar, Polybar, etc.)
|
||||
--
|
||||
-- The file at /tmp/cliamp-now-playing contains the current "Artist - Title"
|
||||
-- and is updated on every track change. Cleaned up on quit.
|
||||
|
||||
local p = plugin.register({
|
||||
name = "now-playing",
|
||||
type = "hook",
|
||||
description = "Write now-playing to /tmp for status bars",
|
||||
})
|
||||
|
||||
local path = p:config("path") or "/tmp/cliamp-now-playing"
|
||||
|
||||
p:on("track.change", function(track)
|
||||
local title = track.title or ""
|
||||
local artist = track.artist or ""
|
||||
local text = title
|
||||
if artist ~= "" then
|
||||
text = artist .. " - " .. title
|
||||
end
|
||||
cliamp.fs.write(path, text)
|
||||
cliamp.log.info("Now playing: " .. text)
|
||||
|
||||
-- Desktop notification via mako/notify-send.
|
||||
if artist ~= "" then
|
||||
cliamp.notify(title, artist)
|
||||
else
|
||||
cliamp.notify(title)
|
||||
end
|
||||
end)
|
||||
|
||||
p:on("playback.state", function(ev)
|
||||
if ev.status == "stopped" then
|
||||
cliamp.fs.write(path, "")
|
||||
end
|
||||
end)
|
||||
|
||||
p:on("app.quit", function()
|
||||
cliamp.fs.remove(path)
|
||||
end)
|
||||
@@ -0,0 +1,43 @@
|
||||
-- status-messages.lua — Demo of cliamp.message(): surface playback events
|
||||
-- as transient messages in the status bar at the bottom of the UI.
|
||||
--
|
||||
-- Install by copying (or symlinking) this file to ~/.config/cliamp/plugins/
|
||||
-- and restart cliamp.
|
||||
|
||||
local p = plugin.register({
|
||||
name = "status-messages",
|
||||
type = "hook",
|
||||
description = "Show playback events in the status bar",
|
||||
})
|
||||
|
||||
p:on("app.start", function()
|
||||
cliamp.message("cliamp ready", 2)
|
||||
end)
|
||||
|
||||
p:on("track.change", function(track)
|
||||
local text = track.title or ""
|
||||
if track.artist and track.artist ~= "" then
|
||||
text = track.artist .. " — " .. text
|
||||
end
|
||||
cliamp.message("Now playing: " .. text, 3)
|
||||
end)
|
||||
|
||||
-- playback.state fires on every tick (~1Hz) during playback, not just on
|
||||
-- state transitions. Track the last status locally so the status bar is
|
||||
-- only updated when it actually changes.
|
||||
local last_status = nil
|
||||
p:on("playback.state", function(ev)
|
||||
if ev.status == last_status then
|
||||
return
|
||||
end
|
||||
last_status = ev.status
|
||||
if ev.status == "paused" then
|
||||
cliamp.message("Paused", 1.5)
|
||||
elseif ev.status == "stopped" then
|
||||
cliamp.message("Stopped", 1.5)
|
||||
end
|
||||
end)
|
||||
|
||||
p:on("track.scrobble", function()
|
||||
cliamp.message("Scrobble sent", 2)
|
||||
end)
|
||||
@@ -0,0 +1,29 @@
|
||||
-- webhook.lua — POST track info to a URL on every track change.
|
||||
--
|
||||
-- Configure the URL in config.toml:
|
||||
-- [plugins.webhook]
|
||||
-- url = "https://example.com/hook"
|
||||
|
||||
local p = plugin.register({
|
||||
name = "webhook",
|
||||
type = "hook",
|
||||
description = "POST track info to a webhook URL",
|
||||
})
|
||||
|
||||
local url = p:config("url")
|
||||
|
||||
p:on("track.change", function(track)
|
||||
if not url then return end
|
||||
local body, status = cliamp.http.post(url, {
|
||||
json = {
|
||||
title = track.title,
|
||||
artist = track.artist,
|
||||
album = track.album,
|
||||
genre = track.genre,
|
||||
path = track.path,
|
||||
}
|
||||
})
|
||||
if status and status >= 400 then
|
||||
cliamp.log.warn("webhook returned " .. tostring(status))
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user