mpv icon indicating copy to clipboard operation
mpv copied to clipboard

notify-send title

Open dev-r34per opened this issue 7 years ago • 1 comments

Hello, i use mpv a lot to stream some youtube playlist with this command alias pmpv='mpv --ytdl-raw-options="yes-playlist="' what do i have to do for the song title to appear with notify-send? for that i found a lua script, but that only notifies the song url

`-- based on https://github.com/rohieb/mpv-notify -- https://unix.stackexchange.com/a/455198/119298 lastcommand = nil function string.shellescape(str) return "'"..string.gsub(str, "'", "'"'"'").."'" end function do_notify(a,b) local command = ("notify-send -a mpv -- %s %s"):format(a:shellescape(), b:shellescape()) if command ~= lastcommand then os.execute(command) lastcommand = command end end function notify_current_track() data = mp.get_property_native("metadata") if data then local artist = (data["ARTIST"] or data["artist"] or " ") local title = (data["TITLE"] or data["title"] or " ") if artist..title~=" " then do_notify(artist, title) return end end local data = mp.get_property("path") if data then local file = data:gsub("^.-([^/]+)$","%1") file = file:gsub("%....$","") -- delete 3 char suffix local dir = data:gsub("^.-([^/]+)/[^/]*$","%1") do_notify(dir, file) end end

mp.register_event("file-loaded", notify_current_track)`

dev-r34per avatar May 29 '19 19:05 dev-r34per

https://github.com/mpv-player/mpv/blob/master/DOCS/man/input.rst get the title/media-title whatever and and do the same as the script already does.

Akemi avatar May 29 '19 22:05 Akemi