Merge branch 'master' of github.com:Nooo37/bling into docs

This commit is contained in:
Gokul Swami 2021-02-16 17:25:50 -08:00
commit 6c7578f79c
2 changed files with 43 additions and 19 deletions

View File

@ -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.

View File

@ -1,11 +1,10 @@
-- Provides:
-- bling::playerctl::status
-- playing (boolean)
-- 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)
@ -86,18 +85,16 @@ echo "$tmp_cover_path"
function()
awful.spawn.with_line_callback(song_follow_cmd, {
stdout = function(line)
-- Get Album Art
awful.spawn.easy_async_with_shell(art_script, function(out)
-- Get album path
local album_path = out:gsub('%\n', '')
awesome.emit_signal("bling::playerctl::album",
album_path)
-- Get Title and Artist
local artist = line:match('artist_(.*)title_')
local title = line:match('title_(.*)')
awesome.emit_signal(
"bling::playerctl::title_artist_album", title,
artist, album_path)
end)
-- Get Title and Artist
local artist = line:match('artist_(.*)title_')
local title = line:match('title_(.*)')
awesome.emit_signal("bling::playerctl::title_artist", title,
artist)
end
})
end)