mirror of
https://github.com/streetturtle/awesome-wm-widgets.git
synced 2024-11-15 19:48:04 +01:00
spotify-widget: check for utf8 support
which is only availble in Lua 5.3+. Tested using Lua 5.1.5
This commit is contained in:
parent
3302e4f921
commit
3164a39b4f
1 changed files with 5 additions and 1 deletions
|
@ -16,6 +16,10 @@ local GET_SPOTIFY_STATUS_CMD = 'sp status'
|
|||
local GET_CURRENT_SONG_CMD = 'sp current'
|
||||
|
||||
local function ellipsize(text, length)
|
||||
-- utf8 only available in Lua 5.3+
|
||||
if utf8 == nil then
|
||||
return text:sub(0, length)
|
||||
end
|
||||
return (utf8.len(text) > length and length > 0)
|
||||
and text:sub(0, utf8.offset(text, length - 2) - 1) .. '...'
|
||||
or text
|
||||
|
@ -154,4 +158,4 @@ end
|
|||
|
||||
return setmetatable(spotify_widget, { __call = function(_, ...)
|
||||
return worker(...)
|
||||
end })
|
||||
end })
|
||||
|
|
Loading…
Reference in a new issue