Displaying item on only one display #205
-
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 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} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
After trying a bit more I made a script based on dynamic space listing posted here and has been working fine. sketchybarrc
sketchybar --add item template.window.title left \
--set template.window.title drawing=off \
script="$PLUGIN_DIR/window.title.sh" \
updates=on \
icon.font="SF Pro:Heavy:13.0" \
icon.color=$COLOR_DESACTIVATED_ICON \
label.color=$COLOR_DESACTIVATED_LABEL \
update_freq=3 \
\
--add item window.title.update left \
--set window.title.update drawing=off \
updates=on \
script="$PLUGIN_DIR/window.title.update.sh" \
--subscribe window.title.update display_number_changed window.title.sh
#!/usr/bin/env bash
if [ "${NAME}" == "template.window.title" ]; then
exit 0
fi
QUERY=$(yabai -m query --windows --window & disown)
TITLE=$(echo "$QUERY" | jq -r '.title')
ACT_DISPLAY=$(echo "$QUERY" | jq -r '.display')
if [ "${INFO}" == "" ]; then
INFO=$(echo "$QUERY" | jq -r '.app')
fi
if [ $ACT_DISPLAY == "$(echo "${NAME}" | cut -d. -f3)" ]; then
sketchybar -m --set ${NAME} icon="${INFO}" label="${TITLE}" drawing=on
else
sketchybar -m --set ${NAME} drawing=off
fi
window.title.update.sh
#!/usr/bin/env bash
args=()
DISPLAYS="$(yabai -m query --displays | jq -rc '.[] | .index | @sh')"
for display in $DISPLAYS; do
args+=(--clone "window.title.${display}" template.window.title before
--set "window.title.${display}" associated_display=${display} drawing=on
--subscribe "window.title.${display}" front_app_switched)
done
sketchybar -m ${args[@]} &>/dev/null |
Beta Was this translation helpful? Give feedback.
-
I have tracked down a bug in the updating logic that prevented the What you are asking for is now possible on current master by doing this: 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 |
Beta Was this translation helpful? Give feedback.
-
Tonight I will upgrade the sketchybar and make these modifications on my scripts. Thanks a lot for fixing the bug so fast. |
Beta Was this translation helpful? Give feedback.
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 thedisplay_change
event: 5d31801What 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