BlingCorp / bling

Utilities for the awesome window manager
https://blingcorp.github.io/bling/
MIT License
846 stars 50 forks source link

Playerctl shows nothing but an empty dot #105

Closed M1ndo closed 3 years ago

M1ndo commented 3 years ago

I was trying to use playerctl module , however it does seem to work for some reason and it only shows a empty dot as notification. in play_ctl.lua there's the following

local naughty = require("naughty")
awesome.connect_signal("bling::playerctl::title_artist_album",
                       function(title, artist, art_path)
    naughty.notify({title = title, text = artist, image = art_path})
end)

And in rc.lua

local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme)
beautiful.init(theme_path)
local bling = require("lib.bling")
require("scripts.play_ctl")
... snip ...
awful.key({ altkey, }, "j", function () awesome.emit_signal("bling::playerctl::title_artist_album") end,
              {description = "Spot Pop Up", group = "Pop Ups"}),

Also Tried to use @Nooo37 bar.lua (Music Section) this one with

awful.key({ modkey, }, "p", 
        function () 
            local last_notify = {}
            awesome.connect_signal("bling::playerctl::title_artist_album", function(title, artist, album)
            last_notify = naughty.notify {
                title=tostring(title),
                text=tostring(artist),
                icon = gears.surface.load_uncached_silently(album),
                timeout=2,
                replaces_id=last_notify.id,
            }
            end)
        end,
        {description = "PlayerCtl Pop Up", group = "Pop Ups"}),

however it didn't work at all i didn't show anything .

Nooo37 commented 3 years ago

I think you haven't enabled the signal with bling.signal.playerctl.enable()? At least I can't find that line in your config. https://blingcorp.github.io/bling/#/signals/pctl

Nooo37 commented 3 years ago

Also mpris support (which is what playerctl uses to get title, album art etc) varies a lot between different players. For some you need dedicated plugins (for example iirc deadbeef, mpd), browsers usually have some sort of mpris support, the lollypop player has great mpris support etc.

M1ndo commented 3 years ago

I think you haven't enabled the signal with bling.signal.playerctl.enable()? At least I can't find that line in your config. https://blingcorp.github.io/bling/#/signals/pctl

yes indeed , however it still show the same thing. here's how i set it up

local theme_path = string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme)
beautiful.init(theme_path)
local bling = require("lib.bling")
bling.signal.playerctl.enable()
require("scripts.play_ctl")

Using your config as mentioned above . when using mod+p (multiple times)doesn't show anything , however when forwarding to another song (Spotify) it displays a notification (how many times it was called) image

M1ndo commented 3 years ago

Also mpris support (which is what playerctl uses to get title, album art etc) varies a lot between different players. For some you need dedicated plugins (for example iirc deadbeef, mpd), browsers usually have some sort of mpris support, the lollypop player has great mpris support etc.

yes tho this shouldn't be the case for spotify .

Nooo37 commented 3 years ago

Oh yeah, I should have looked at the snippets you provided before jumping into your config lol. So the last two snippets don't make much sense: awesome.connect_signal("bling::playerctl::title_artist_album", function(param1, param2, ...) .... end means "run the given function everytime that the signal bling::playerctl::title_artist_album gets emitted (through awesome.emit_signal("bling::playerctl::title_artist_album", param1, param2, ...))". All that bling does (from a user perspective) is to emit the singal with the right parameters so that your function can access the necessary info.

yes tho this shouldn't be the case for spotify .

Ehhh. Spotify doesn't care that much. But it seems to work for you just fine considering the screenshot

M1ndo commented 3 years ago

Apparently i misunderstood the documentation, and the code i wrote made nonsense (which i finally understood it myself hours later lol),i thought this works like scratchpads . you assign a keybinding and it pops up shows you what u need and eventually timeout like your volume pop up . this there any way i can get something like this to pop up image

Nooo37 commented 3 years ago

Sure there is a way. You create such a widget and then update the info on there based on the incomming signal. For my current widget that looks something like:

awesome.connect_signal("bling::playerctl::title_artist_album", function(title, artist, album_path)
    mytextbox.markup = tostring(title) .. " - " .. tostring(artist)
    myimagebox:set_image(gears.surface.load_uncached_silently(album_path))
    myimagebox:emit_signal("widget::redraw_needed")
end)

And then you would also need to add a timeout similar to the one you saw in my volume pop up.

Doing all of that at once might be a little too much though. Since you don't seem to be familiar with signals yet I would advise you to get the following working before attempting the popup: Add a textbox to your wibar and make the textbox display the current song title by connecting to the bling signal. Everything else is really just an extension of that principle.

M1ndo commented 3 years ago

i finally understood how playerctl signals work , i managed to create a pop up that displays title - artist like shown below , however couldn't fit progressbar. meanwhile i got album_art to work after changing some stuff in playerctl_cli.lua , spotify artUrl is handled weirdly by default . Spotify mpris:artUrl looks like this https://open.spotify.com/image/song_id and downloading doesn't result to art cover file instead it just downloads a 403 page , in order to download the cover file u place this https://i.scdn.co/image/Song_id which will then download the cover.png . To Fix this either by adding this

link="$(playerctl metadata mpris:artUrl | cut -d/ -f5)"
curl -s "https://i.scdn.co/image/$link" --output $tmp_cover_path

or by adding this in your /etc/hosts file to redirect any requests from https://open.spotify.com/ to https://i.scdn.co

151.101.38.248                open.spotify.com

Here's config ctl_pop.lua

Nooo37 commented 3 years ago

i finally understood how playerctl signals work

Then you also understood how every other signal in awesomewm works :partying_face:

downloading doesn't result to art cover file instead it just downloads a 403 page

Yes, that's what I meant with "they don't care that much": https://community.spotify.com/t5/Desktop-Linux/MPRIS-cover-art-url-file-not-found/td-p/4920104

Anyway, I don't really want to teach widgeting in bling github issues. I don't think it's the right place nor do I think that the format performs that well with that task (feels like emailing to me). If you need that kind of quick, more general help, consider joining the unofficial awesomeWM discord server (just search on the subreddit for an invite link from a year ago) or the IRC I guess.