-
-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathtrack-info-popup.lua
More file actions
31 lines (28 loc) · 1.05 KB
/
Copy pathtrack-info-popup.lua
File metadata and controls
31 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- track-info-popup: a `track_info` command that opens a popup with the current track details.
--
-- Install (single file; see PLUGINS.md for config path rules):
-- cp track-info-popup.lua "${XDG_CONFIG_HOME:-$HOME/.config}/spotatui/plugins/"
--
-- Suggested binding, in config.yml in the spotatui app config directory:
-- plugin_commands:
-- track_info: "ctrl-i"
spotatui.register_command("track_info", function()
local pb = spotatui.playback()
if not pb or not pb.track then
spotatui.notify("Nothing is playing", 3)
return
end
local t = pb.track
local minutes = math.floor(t.duration_ms / 60000)
local seconds = math.floor((t.duration_ms % 60000) / 1000)
spotatui.popup("Track info", {
{ text = t.name, bold = true, fg = "Green" },
{ text = "by " .. table.concat(t.artists, ", "), fg = "Cyan" },
{ text = "on " .. t.album },
"",
string.format("Length: %d:%02d", minutes, seconds),
{ text = pb.is_playing and "Playing" or "Paused", fg = pb.is_playing and "Green" or "Yellow" },
"",
"Press Esc to close",
})
end)