Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
6.42k stars 696 forks source link

MPRIS Widget feature suggestion, remove "- YouTube" and "- YouTube Music" from title #2730

Open Jeffser opened 10 months ago

Jeffser commented 10 months ago

Hi, I noticed that playerctl reports the title of music played in YouTube Music as "{actual title} - YouTube Music" maybe we could add a parameter to the widget that allows to replace "- YouTube Music" with an empty string, that way it could be removed, for now I've been using a custom script like this

#!/bin/bash

title=$(playerctl metadata title | sed -e 's/ - YouTube Music//; s/ - YouTube//; s/&/\&/g; s/"/\\\"/g' | tr -d '\n')
status=$(playerctl status | tr -d '\n')

if [ ! -z "$title" ]; then
    echo "{\"alt\": \"$status\", \"tooltip\": \"$title\", \"text\": \"$title\"}" 
fi
"custom/playerctl": {
        "interval": 1,
        "format": "{icon} {}",
        "max-length": 40,
        "exec": "~/.config/waybar/scripts/playerctl.sh",
        "on-click": "playerctl play-pause",
        "on-scroll-up": "playerctl next",
        "on-scroll-down": "playerctl previous",
        "scroll-step": 10,
        "return-type": "json",
        "format-icons": {
            "Playing": "󰎈",
            "Paused": "󰏤"
        }
    },
inventor500 commented 9 months ago

YouTube is hardly the only site to do this. Twitter, for example, uses the following format: <name> on X: "<title>: <link>" / X, and The New York Times uses <title> - The New York Times. If waybar adds special coding for YouTube music, then it should do so in a way that supports every site that does this. Maybe a custom regex field?