Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying the maximum song title length before scrolling begins in spotify-widget #366

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spotify-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
35 changes: 24 additions & 11 deletions spotify-widget/spotify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,36 @@ 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

local cur_artist = ''
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',
Expand All @@ -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)
Expand Down