FelixKratz / SketchyBar

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

[FR] Scrolling text animation #429

Closed albert-ying closed 9 months ago

albert-ying commented 9 months ago

It would be nice to have lengthy text automatically scrolling in the bar. (like in simple-bar

Is it implementable with the current or modified animate backend?

FelixKratz commented 9 months ago

I have played with text scrolling a bit here: 2ba5a6c

Currently looks like this:

https://github.com/FelixKratz/SketchyBar/assets/22680421/60bb705e-adac-4101-9860-013b697eedf9

with

sketchybar --set <name> scroll_texts=<boolean>

being applied to texts where the max_chars property is used to truncate the strings.

I will play with this some more and try to readd the ellipsis char at the right hand side of the scroll.

Is this how you would have imagined the text scrolling to work?

albert-ying commented 9 months ago

Yes, it looks great! BTW, does this widget you used in the screenshot also works for apple music?

albert-ying commented 9 months ago

I just updated and tried. It seems doesn't work to me. Is this config correct?

sketchybar --add item test right \
  --set test scroll_texts=on \
  max_chars=5 \
  label="This is a long test text that should scroll"

CleanShot 2023-10-30 at 16 20 39@2x

FelixKratz commented 9 months ago

You need to set the max_chars property on the label, i.e.

sketchybar --set test label.max_chars=5
albert-ying commented 9 months ago

Ah I see, working now!

The default scrolling speed is a bit too fast tho, would be nice to be able to adjust that (or slower default). Thank you!

CleanShot 2023-10-30 at 16 46 36

edit: lol definitely too fast, it induces some dizziness... And it doesn't make much sense to go backward to me (as you don't really read backward, and I guess this is the major cause of dizziness). Not trying to be nitpicking here, this is great already!

FelixKratz commented 9 months ago

Yeah looks a bit fast, thats probably because it has the same total duration regardless of actual text length.

If you want you can play with the parameters and see if you find something that you like:

The 15 in this line makes the text scroll every 15 seconds: https://github.com/FelixKratz/SketchyBar/blob/9d9529cb79de62ded7346abfaf2a0bcc6cf70bd2/src/bar_item.c#L110

And here the animation itself is configured (300 meaning 300/60 = 5 seconds animation duration) the second ANIMATE_FLOAT macro is the one that makes it go backwards: https://github.com/FelixKratz/SketchyBar/blob/9d9529cb79de62ded7346abfaf2a0bcc6cf70bd2/src/text.c#L266-L284

If you find something that is nice and would generalize well you can post it here or create a PR if you like.

FelixKratz commented 9 months ago

I have updated this to look a bit better.