diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2023-05-17 00:09:51 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2023-05-17 00:09:51 +0200 |
| commit | 5d3c0b24405381a41bd13a3135fa2969c2b47a48 (patch) | |
| tree | c59a2521159b90daac9e139e5ebaeaf24dd3fa0f /mpv/music/local.lua | |
| parent | 436159f3542d4e11c81ff927ab6b22f5ad2619e0 (diff) | |
| parent | ca1fba1ef518b2f55bc168e9782b500dfec67c16 (diff) | |
Merge branch 'main' of https://github.com/Laitram31/config
Diffstat (limited to 'mpv/music/local.lua')
| -rw-r--r-- | mpv/music/local.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mpv/music/local.lua b/mpv/music/local.lua new file mode 100644 index 0000000..dfb9e2d --- /dev/null +++ b/mpv/music/local.lua @@ -0,0 +1,30 @@ +local utils = require "mp.utils" + +function notify_current_media() + local path = mp.get_property_native("path") + local origin, title = utils.split_path(path) + + local metadata = mp.get_property_native("metadata") + if metadata then + function tag(name) + return metadata[string.upper(name)] or metadata[name] + end + + title = tag("title") or title + origin = tag("artist_credit") or tag("artist") or "" + + local album = tag("album") + if album then + origin = string.format("%s — %s", origin, album) + end + + local year = tag("original_year") or tag("year") + if year then + origin = string.format("%s (%s)", origin, year) + end + end + mp.command_native({"run", "pkill", "-RTMIN+1", "dwmblocks"}) + return mp.command_native({"run", "env", "HERBE_ID=/music", "herbe", title, origin}) +end + +mp.register_event("file-loaded", notify_current_media)
\ No newline at end of file |
