3 ms·
I am curious as to why not just use: playerctl metadata artist playerctl metadata title as provided by MPRIS https://wiki.archlinux.org/title/MPRIS h
by tetris11 3y ago
I am curious as to why not just use:
playerctl metadata artist
playerctl metadata title
as provided by MPRIS
https://wiki.archlinux.org/title/MPRIS https://wiki.archlinux.org/title/MPRIS
> MPRIS (Media Player Remote Interfacing Specification) is a standard D-Bus interface which aims to provide a common programmatic API for controlling media players.
> It provides a mechanism for discovery, querying and basic playback control of compliant media players, as well as a track list interface which is used to add context to the active media item.
- hifromwork 3y agoBecause it's an article about linux text manipulation, not about solving this specific problem.
- dmonitor 3y agoThere's a lot of better ways to do this. For starters, the sp script is bash. He could just edit the script. There's also a function for returning the metadata in machine-parseable syntax: function sp-metadata { # Prints the currently playing track in a parseable format. dbus-send \ --print-reply `# We need the reply.` \ --dest=$SP_DEST \ $SP_PATH \ org.freedesktop.DBus.Properties.Get \ string:"$SP_MEMB" string:'Metadata' \ | grep -Ev "^method" `# Ignore the first line.` \ | grep -Eo '("(.*)")|(\b[0-9][a-zA-Z0-9.]*\b)' `# Filter interesting fiels.`\ | sed -E '2~2 a|' `# Mark odd fields.` \ | tr -d '\n' `# Remove all newlines.` \ | sed -E 's/\|/\n/g' `# Restore newlines.` \ | sed -E 's/(xesam:)|(mpris:)//' `# Remove ns prefixes.` \ | sed -E 's/^"//' `# Strip leading...` \ | sed -E 's/"$//' `# ...and trailing quotes.` \ | sed -E 's/"+/|/' `# Regard "" as seperator.` \ | sed -E 's/ +/ /g' `# Merge consecutive spaces.` } But as the other replier mentioned, the point was to show off an example of how text manipulation skills can solve many problems, not solve this specific problem in the best way possible.
- junkblocker 3y agoTIL a neat way to add comments to continued shell lines. Thanks!