From cbd9490eadaa2c41bb352028be4032d828f3dd40 Mon Sep 17 00:00:00 2001 From: gokul swaminathan <33443763+JavaCafe01@users.noreply.github.com> Date: Tue, 16 Feb 2021 17:22:00 -0800 Subject: [PATCH] Update README.md --- README.md | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fb16d93..ccc04b3 100644 --- a/README.md +++ b/README.md @@ -224,11 +224,10 @@ To enable: `bling.signal.playerctl.enable()` ```lua -- bling::playerctl::status -- first line is the signal -- playing (boolean) -- indented lines are function parameters --- bling::playerctl::album --- album_art (string) --- bling::playerctl::title_artist +-- bling::playerctl::title_artist_album -- title (string) -- artist (string) +-- album_path (string) -- bling::playerctl::position -- interval_sec (number) -- length_sec (number) @@ -236,7 +235,6 @@ To enable: `bling.signal.playerctl.enable()` ###### Example Implementation -Lets say we have an imagebox. If I wanted to set the imagebox to show the album art, all I have to do is this: ```lua local art = wibox.widget { image = "default_image.png", @@ -246,11 +244,40 @@ local art = wibox.widget { widget = wibox.widget.imagebox } -awesome.connect_signal("bling::playerctl::album", function(path) - art:set_image(gears.surface.load_uncached(path)) +local title_widget = wibox.widget { + markup = 'Nothing Playing', + align = 'center', + valign = 'center', + widget = wibox.widget.textbox +} + +local artist_widget = wibox.widget { + markup = 'Nothing Playing', + align = 'center', + valign = 'center', + widget = wibox.widget.textbox +} + +-- Get Song Info +awesome.connect_signal("bling::playerctl::title_artist_album", + function(title, artist, art_path) + -- Set art widget + art:set_image(gears.surface.load_uncached(art_path)) + + local my_title = "No Title" + local my_artist = "No Artist" + + if title then + my_title = title + my_artist = artist + end + + -- Set title and artist widgets + title_widget:set_markup_silently(my_title) + artist_widget:set_markup_silently(my_artist) end) ``` -Thats all! You don't even have to worry about updating the imagebox, the signals will handle that for you. +Thats all! You don't even have to worry about updating the widgets, the signals will handle that for you.