mihirlad55 / polybar-spotify-module

A collection of lightweight programs for use with a Polybar Spotify Module
GNU General Public License v3.0
140 stars 9 forks source link

Truncating non-ascii characters displays unprintable characters causing polybar to freak out. #34

Open vymvn opened 1 year ago

vymvn commented 1 year ago

As the title says, long non-english song titles sometimes have this bug when truncated.

Polybar log error:

polybar|warn:  Dropping unmatched character  (U+0011) in '  Твин Пикс - По шанхай�.'

The bar gets completely blanked out and blurred by my compositer (picom). And if I kill picom it will just be a blank black line.

Also I have noticed that some non-english titles get truncated as normal but some cause this. The non-english titles that broke it with me is Russian and Arabic characters.

Steps to reproduce:

[module/spotify]
type = custom/ipc
; Default
hook-0 = echo ""
; Playing/paused show song name and artist
hook-1 = spotifyctl -q status --format '%artist% - %title%' --max-length 50 --max-title-length 20 --max-artist-length 20 --trunc '..'

https://open.spotify.com/track/26HmgTNZiSyTtK8iWw8cxv?si=b0da790af46e445d

Also here is an example of a song witch Russian characters that gets truncated normally:

https://open.spotify.com/track/5Qbmmuhe3kvAFZ4Oe6kfmP?si=f38ba013e05a499f

I have tried to fix by messing with truncating function in utils.c but I couldn't figure it out.