FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.62k stars 86 forks source link

Popup width #355

Closed khaneliman closed 1 year ago

khaneliman commented 1 year ago

Is it currently possible to set the width of a popup or a max-width to prevent one from growing too large from items contained within it? I couldn't seem to find a way to implement this.

FelixKratz commented 1 year ago

The width of a popup is controlled by the widest item in the popup. Items have no way to set a maximum "content-length". The width property only controls the width of the "reserved space" for that item and the content can outgrow this reserved space.

So, currently, the width of the popup can be controlled by truncating the content of the widest item only, e.g.

TRUNCATED="$(echo "$CONTENT" | sed 's/\(.\{20\}\).*/\1.../')"

truncates the $CONTENT at 20 characters with three dots. Thats the way I did it for my spotify popup widget: https://github.com/FelixKratz/dotfiles/blob/13b61b202972fe0e97f0afc8b2eeca38cd9c09dd/.config/sketchybar/plugins/spotify.sh#L47