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

associated_display property is not applied instantaneously #206

Closed
FelixKratz opened this issue Jun 26, 2022 Discussed in #205 · 1 comment
Closed

associated_display property is not applied instantaneously #206

FelixKratz opened this issue Jun 26, 2022 Discussed in #205 · 1 comment
Labels
available on master bug Something isn't working
Milestone

Comments

@FelixKratz
Copy link
Owner

FelixKratz commented Jun 26, 2022

A change in the associated_display property does not cause a redraw. It has been fixed with: 5d31801, for details see below.

Discussed in #205

Originally posted by diegolhambi June 25, 2022
Thanks for making such a great and customizable bar.

So, I am trying to show the window title only in the display active, tried using associated_display on the updater script but this seen not work well. Any ideas? 😕

sketchybarrc

sketchybar --add item         window.title left                     \
          --set window.title script="$PLUGIN_DIR/window.title.sh"  \
                              icon.font="SF Pro:Heavy:13.0"         \
                              icon.color=$COLOR_DESACTIVATED_ICON   \
                              label.color=$COLOR_DESACTIVATED_LABEL \
                              update_freq=3                         \
          --subscribe        window.title front_app_switched

window.title.sh

#!/usr/bin/env bash

source "$(pwd)/colors.sh"

QUERY=$(yabai -m query --windows --window)
TITLE=$(echo "$QUERY" | jq -r '.title')
DISPLAY=$(echo "$QUERY" | jq -r '.display')

if [ "${INFO}" == "" ]; then
  INFO=$(echo "$QUERY" | jq -r '.app')
fi

sketchybar -m --set ${NAME} icon="${INFO}" label="${TITLE}" associated_display=${DISPLAY}

@FelixKratz FelixKratz added bug Something isn't working available on master labels Jun 26, 2022
@FelixKratz FelixKratz changed the title associated_display property is not applied instantanously associated_display property is not applied instantaneously Jun 26, 2022
@FelixKratz
Copy link
Owner Author

FelixKratz commented Jun 26, 2022

I have tracked down a bug in the updating logic that prevented the associated_display property to apply correctly. Also I have added the active display id to the $INFO variable for the display_change event: 5d31801

What you are asking for is now possible on current master by doing this:
sketchybarrc

sketchybar --add       system.label       left                                 \
           --set       system.label       label=Window                         \
                                          script="$PLUGIN_DIR/window_title.sh" \
           --subscribe system.label       front_app_switched display_change

window_title.sh

#!/usr/bin/env sh

case "$SENDER" in
  "front_app_switched") sketchybar --set $NAME label="$INFO"
  ;;
  "display_change") sketchybar --set $NAME associated_display=$INFO
  ;;
esac

@FelixKratz FelixKratz added this to the v2.7.2 milestone Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
available on master bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant