Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flickering on items with scrolling text enabled #507

Open
OneComputerGuy opened this issue Feb 17, 2024 · 9 comments
Open

Flickering on items with scrolling text enabled #507

OneComputerGuy opened this issue Feb 17, 2024 · 9 comments
Labels
bug Something isn't working not reproducible

Comments

@OneComputerGuy
Copy link

Sometimes (around 40% of the time) I get a weird flickering on items that have scrolling text such as the battery item or the Now Playing item I have.

A restart of the bar clears it most of the time but sometimes it sticks.

Video of the issue:

Screen.Recording.2024-02-16.at.7.59.56.PM.mov

The item file has this:

#!/bin/zsh

sketchybar --add item battery right \
            --set battery label.font.size=13.0 \
                                script="$PLUGIN_DIR/battery.sh" \
                                update_freq=120 \
            --subscribe battery system_woke power_source_change

and the plugin file has the following:

#!/bin/sh

PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
TIME_LEFT=$(pmset -g batt | grep -Eo "\d+:\d+")
CHARGING=$(pmset -g batt | grep 'AC Power')
CALCULATED_TIME="..."

if [ $PERCENTAGE = "" ]; then
  exit 0
fi

case ${PERCENTAGE} in
  9[0-9]|100) ICON="􀛨"
  ;;
  [6-8][0-9]) ICON="􀺸"
  ;;
  [3-5][0-9]) ICON="􀺶"
  ;;
  [1-2][0-9]) ICON="􀛩"
  ;;
  *) ICON="􀛪"
esac

if [[ $CHARGING != "" ]]; then
  ICON="􀢋"
fi

if [[ -z $TIME_LEFT  ]]; then
  echo "Remaining time: $TIME_LEFT"
  TIME_LABEL="--:--"
else
  TIME_LABEL=$TIME_LEFT
fi

sketchybar --set $NAME label.width=42 label.max_chars=5 scroll_texts=true label.align=center icon="$ICON" label="$TIME_LABEL       $PERCENTAGE%"

The bar has the following styles and settings:

BAR_STYLES_BOTTOM=(
  position=bottom
  sticky=off
  topmost=window
  height=40
  blur_radius=30
  padding_left=10
  padding_right=10
  color=$BAR_COLOR
)
@OneComputerGuy
Copy link
Author

One thing to add is that I've tried without the sticky option and sometimes I get the same behavior

@OneComputerGuy OneComputerGuy changed the title Weird flickering on items with scrollint text enabled Weird flickering on items with scrolling text enabled Feb 18, 2024
@FelixKratz
Copy link
Owner

I am not able to reproduce on macOS sonoma with this minimal config:

sketchybarrc

#!/bin/zsh

SCRIPT='
#!/bin/sh

PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
TIME_LEFT=$(pmset -g batt | grep -Eo "\d+:\d+")
CHARGING=$(pmset -g batt | grep "AC Power")
CALCULATED_TIME="..."

if [ $PERCENTAGE = "" ]; then
  exit 0
fi

case ${PERCENTAGE} in
  9[0-9]|100) ICON="􀛨"
  ;;
  [6-8][0-9]) ICON="􀺸"
  ;;
  [3-5][0-9]) ICON="􀺶"
  ;;
  [1-2][0-9]) ICON="􀛩"
  ;;
  *) ICON="􀛪"
esac

if [[ $CHARGING != "" ]]; then
  ICON="􀢋"
fi

if [[ -z $TIME_LEFT  ]]; then
  echo "Remaining time: $TIME_LEFT"
  TIME_LABEL="--:--"
else
  TIME_LABEL=$TIME_LEFT
fi

sketchybar --set $NAME label.width=42 label.max_chars=5 scroll_texts=true label.align=center icon="$ICON" label="$TIME_LABEL       $PERCENTAGE%"
'


sketchybar --bar color=0xff000000 sticky=off topmost=window

sketchybar --add item battery right \
            --set battery label.font.size=13.0 \
                                script="$SCRIPT" \
                                update_freq=120 \
            --subscribe battery system_woke power_source_change

sketchybar --update

could you confirm that it happens with this exact config as well? Which macOS version are you running?

@FelixKratz FelixKratz added bug Something isn't working not reproducible labels Feb 18, 2024
@FelixKratz FelixKratz changed the title Weird flickering on items with scrolling text enabled Flickering on items with scrolling text enabled Feb 18, 2024
@OneComputerGuy
Copy link
Author

I've changed the config and will run it for a while to see if I get the same behavior. As for the macOS version, I'm running Sonoma, version 14.3.1 with 16Gb of RAM.

Not sure if relevant, but I switch regularly between a 4k monitor with the MacBook in clamshell mode and the laptop built-in monitor. I got the same behavior in both, but not sure if the change of displays could be triggering something else.

@OneComputerGuy
Copy link
Author

Bit of an update, I ran the config you posted @FelixKratz and I'm not seeing any other glitch which is good, however, I kinda know now where the issue might be coming from.

I've modified the config file you posted and changed the font.size property to this:

--set battery label.font="Fredoka:Regular:13.0"

With that modification, the issue started again (not immediately but after a few hours of work). Fredoka is this Google Font but I've got this issue also with fonts from NerdFonts.

Home that helps to scope the issue a bit more

@Nikolaidp24
Copy link

I noticed the same thing happening with my music item as well, and I use OperatorMono Nerd Font. Also the texts sometimes seem a bit laggy when it's not flickering.

@OneComputerGuy
Copy link
Author

I got more replication info today. I was able to get the same behavior with a stripped down version of the config I had (only the item without styles) and I was able to get the same behavior.

For this replication, I was able to remove the background, font, and styles from the item, was able to leave only the battery indicator. The only thing I wasn't able to get was to put the bar completely black, not sure if the transparency of the bar is what causing the issue

One thing I noticed right away is that the issue was more noticeable when the bar had position=bottom instead of on the top as seen in this video (around 2 out of 10 times was visible on the top instead of the 7/10 on the bottom):

Screen.Recording.2024-02-27.at.5.05.51.PM.mov

@OneComputerGuy
Copy link
Author

OneComputerGuy commented Feb 27, 2024

And tinkering again, I got the same behavior using the config file you posted initially below (adding the position bottom to the bar though). This is the video:

With custom font

Screen.Recording.2024-02-27.at.5.56.22.PM.mov

Without custom font:

Screen.Recording.2024-02-27.at.5.59.40.PM.mov

I am not able to reproduce on macOS sonoma with this minimal config:

sketchybarrc

#!/bin/zsh

SCRIPT='
#!/bin/sh

PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
TIME_LEFT=$(pmset -g batt | grep -Eo "\d+:\d+")
CHARGING=$(pmset -g batt | grep "AC Power")
CALCULATED_TIME="..."

if [ $PERCENTAGE = "" ]; then
  exit 0
fi

case ${PERCENTAGE} in
  9[0-9]|100) ICON="􀛨"
  ;;
  [6-8][0-9]) ICON="􀺸"
  ;;
  [3-5][0-9]) ICON="􀺶"
  ;;
  [1-2][0-9]) ICON="􀛩"
  ;;
  *) ICON="􀛪"
esac

if [[ $CHARGING != "" ]]; then
  ICON="􀢋"
fi

if [[ -z $TIME_LEFT  ]]; then
  echo "Remaining time: $TIME_LEFT"
  TIME_LABEL="--:--"
else
  TIME_LABEL=$TIME_LEFT
fi

sketchybar --set $NAME label.width=42 label.max_chars=5 scroll_texts=true label.align=center icon="$ICON" label="$TIME_LABEL       $PERCENTAGE%"
'


sketchybar --bar color=0xff000000 sticky=off topmost=window

sketchybar --add item battery right \
            --set battery label.font.size=13.0 \
                                script="$SCRIPT" \
                                update_freq=120 \
            --subscribe battery system_woke power_source_change

sketchybar --update

could you confirm that it happens with this exact config as well? Which macOS version are you running?

@FelixKratz
Copy link
Owner

FelixKratz commented Feb 28, 2024

Could you try with current master? I think I know why this was happening now:

brew uninstall sketchybar
brew install sketchybar --head
brew services restart sketchybar

and then to go back to latest stable release use:

brew uninstall sketchybar
brew install sketchybar
brew services restart sketchybar

My hypthesis would also explain why it is font and position dependent and why I was not able to reproduce it. Because I can still not reproduce it, please confirm if it worked.

@OneComputerGuy
Copy link
Author

I performed the steps to remove and install from head but unfortunately, the issue still exists.

Funny thing, I can see it flicker on my screen but when I try to record it using cmd+shift+5, the bar doesn't do it anymore and works as expected fow a while

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working not reproducible
Projects
None yet
Development

No branches or pull requests

3 participants