diff --git a/spotify-widget/README.md b/spotify-widget/README.md index 3d185597..941a1bf1 100644 --- a/spotify-widget/README.md +++ b/spotify-widget/README.md @@ -31,7 +31,8 @@ It is possible to customize widget by providing a table with all or some of the | `font` | `Play 9`| Font | | `dim_when_paused` | `false` | Decrease the widget opacity if spotify is paused | | `dim_opacity` | `0.2` | Widget's opacity when dimmed, `dim_when_paused` should be set to `true` | -| `max_length` | `15` | Maximum lentgh of artist and title names. Text will be ellipsized if longer. | +| `max_length` | `15` | Maximum length of the artist and title name labels before ellipsizing. -1 prevents ellipsizing entirely. | +| `title_scroll_length` | `100` | Maximum length of title name before it begins scrolling. -1 prevents scrolling entirely. | | `show_tooltip` | `true` | Show tooltip on hover with information about the playing song | | `timeout` | 1 | How often in seconds the widget refreshes | diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index f8df1eac..3e4ac237 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -37,6 +37,7 @@ local function worker(user_args) local dim_when_paused = args.dim_when_paused == nil and false or args.dim_when_paused local dim_opacity = args.dim_opacity or 0.2 local max_length = args.max_length or 15 + local title_scroll_length = args.title_scroll_length or 100 local show_tooltip = args.show_tooltip == nil and true or args.show_tooltip local timeout = args.timeout or 1 @@ -44,6 +45,28 @@ local function worker(user_args) local cur_title = '' local cur_album = '' + local title_widget = (function() + if title_scroll_length >= 0 then + return { + layout = wibox.container.scroll.horizontal, + max_size = title_scroll_length, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + speed = 40, + { + id = 'titlew', + font = font, + widget = wibox.widget.textbox + } + } + else + return { + id = 'titlew', + font = font, + widget = wibox.widget.textbox + } + end + end)() + spotify_widget = wibox.widget { { id = 'artistw', @@ -54,17 +77,7 @@ local function worker(user_args) id = "icon", widget = wibox.widget.imagebox, }, - { - layout = wibox.container.scroll.horizontal, - max_size = 100, - step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, - speed = 40, - { - id = 'titlew', - font = font, - widget = wibox.widget.textbox - } - }, + title_widget, layout = wibox.layout.align.horizontal, set_status = function(self, is_playing) self.icon.image = (is_playing and play_icon or pause_icon)