diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2018-11-05 09:10:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 09:10:45 -0500 |
commit | fa5bec9fc4bb32e692e304b92ca15500ffb140fe (patch) | |
tree | df1f107536f18b578e2f8683129a27194f93e558 | |
parent | 1d59dd36374446d8761d289c7bb4987ba00a833d (diff) | |
parent | be68535271043437d339d2992498deabffd5ab9e (diff) |
Merge pull request #57 from hramezani/add_current_song_to_mpdarc_widget
Add current song text box to mpdarc-widget.
-rw-r--r-- | mpdarc-widget/mpdarc.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index 7b8aea3..da596f6 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -46,9 +46,15 @@ local mpdarc = wibox.widget { 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 current_song = string.gmatch(stdout, "[^\r\n]+")() stdout = string.gsub(stdout, "\n", "") local mpdpercent = string.match(stdout, "(%d%d)%%") local mpdstatus = string.match(stdout, "%[(%a+)%]") @@ -56,13 +62,16 @@ local update_graphic = function(widget, stdout, _, _, _) icon.image = PLAY_ICON_NAME widget.colors = { beautiful.widget_main_color } 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 widget.colors = { beautiful.widget_main_color } widget.value = tonumber(mpdpercent/100) + mpdarc_current_song_widget.markup = current_song else icon.image = STOP_ICON_NAME widget.colors = { beautiful.widget_red } + mpdarc_current_song_widget.markup = "" end end @@ -98,4 +107,9 @@ mpdarc:connect_signal("mouse::leave", function() naughty.destroy(notification) e 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 |