diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2022-02-20 15:05:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-20 15:05:37 -0500 |
commit | 90958abb48cb3353ae109123d9950b77ecf106d8 (patch) | |
tree | 55e020ccfa9de5ba72fa4917b5de501c555ddd7d | |
parent | 3975a9d01b0dd6125d1828ea2a471ac1cd9bd397 (diff) | |
parent | 3164a39b4f0f6188a5ead57fa1fb58ed8ca1adbd (diff) |
Merge pull request #335 from nuno-silva/spotify-widget-utf8
spotify-widget: check for utf8 support
-rw-r--r-- | spotify-widget/spotify.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua index 0eb302a..f8df1ea 100644 --- a/spotify-widget/spotify.lua +++ b/spotify-widget/spotify.lua @@ -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 })
\ No newline at end of file +end }) |