diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2018-11-05 11:54:50 +0100 | 
|---|---|---|
| committer | Hasan Ramezani <hasan.r67@gmail.com> | 2018-11-05 11:54:50 +0100 | 
| commit | be68535271043437d339d2992498deabffd5ab9e (patch) | |
| tree | 90e8fbcfab57e292cbef7d29318546c39ef7e23f /mpdarc-widget/mpdarc.lua | |
| parent | 4215fc7e92ef168c1daabc7db227c3748c1edda4 (diff) | |
Add current song text box to mpdarc-widget.
Diffstat (limited to 'mpdarc-widget/mpdarc.lua')
| -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  | 
