Merge pull request #57 from hramezani/add_current_song_to_mpdarc_widget
Add current song text box to mpdarc-widget.
This commit is contained in:
commit
fa5bec9fc4
|
@ -46,9 +46,15 @@ local mpdarc = wibox.widget {
|
||||||
widget = wibox.container.arcchart
|
widget = wibox.container.arcchart
|
||||||
}
|
}
|
||||||
|
|
||||||
local mpdarc_widget = wibox.container.mirror(mpdarc, { horizontal = true })
|
local mpdarc_icon_widget = wibox.container.mirror(mpdarc, { horizontal = true })
|
||||||
|
local mpdarc_current_song_widget = wibox.widget {
|
||||||
|
id = 'current_song',
|
||||||
|
widget = wibox.widget.textbox,
|
||||||
|
font = 'Play 9'
|
||||||
|
}
|
||||||
|
|
||||||
local update_graphic = function(widget, stdout, _, _, _)
|
local update_graphic = function(widget, stdout, _, _, _)
|
||||||
|
local current_song = string.gmatch(stdout, "[^\r\n]+")()
|
||||||
stdout = string.gsub(stdout, "\n", "")
|
stdout = string.gsub(stdout, "\n", "")
|
||||||
local mpdpercent = string.match(stdout, "(%d%d)%%")
|
local mpdpercent = string.match(stdout, "(%d%d)%%")
|
||||||
local mpdstatus = string.match(stdout, "%[(%a+)%]")
|
local mpdstatus = string.match(stdout, "%[(%a+)%]")
|
||||||
|
@ -56,13 +62,16 @@ local update_graphic = function(widget, stdout, _, _, _)
|
||||||
icon.image = PLAY_ICON_NAME
|
icon.image = PLAY_ICON_NAME
|
||||||
widget.colors = { beautiful.widget_main_color }
|
widget.colors = { beautiful.widget_main_color }
|
||||||
widget.value = tonumber((100-mpdpercent)/100)
|
widget.value = tonumber((100-mpdpercent)/100)
|
||||||
elseif mpdstatus == "paused" then
|
mpdarc_current_song_widget.markup = current_song
|
||||||
|
elseif mpdstatus == "paused" then
|
||||||
icon.image = PAUSE_ICON_NAME
|
icon.image = PAUSE_ICON_NAME
|
||||||
widget.colors = { beautiful.widget_main_color }
|
widget.colors = { beautiful.widget_main_color }
|
||||||
widget.value = tonumber(mpdpercent/100)
|
widget.value = tonumber(mpdpercent/100)
|
||||||
|
mpdarc_current_song_widget.markup = current_song
|
||||||
else
|
else
|
||||||
icon.image = STOP_ICON_NAME
|
icon.image = STOP_ICON_NAME
|
||||||
widget.colors = { beautiful.widget_red }
|
widget.colors = { beautiful.widget_red }
|
||||||
|
mpdarc_current_song_widget.markup = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -98,4 +107,9 @@ mpdarc:connect_signal("mouse::leave", function() naughty.destroy(notification) e
|
||||||
|
|
||||||
watch(GET_MPD_CMD, 1, update_graphic, mpdarc)
|
watch(GET_MPD_CMD, 1, update_graphic, mpdarc)
|
||||||
|
|
||||||
|
local mpdarc_widget = {
|
||||||
|
mpdarc_icon_widget,
|
||||||
|
mpdarc_current_song_widget,
|
||||||
|
layout = wibox.layout.align.horizontal,
|
||||||
|
}
|
||||||
return mpdarc_widget
|
return mpdarc_widget
|
||||||
|
|
Loading…
Reference in New Issue