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

Add AEROSPACE_EMPTY_WORKSPACES env var to exec-on-workspace-change #430

Closed
3 tasks done
karamanliev opened this issue Aug 19, 2024 · 1 comment
Closed
3 tasks done

Comments

@karamanliev
Copy link

karamanliev commented Aug 19, 2024

Adding AEROSPACE_EMPTY_WORKSPACES to the exec-on-workspace-change event will make it possible to dynamically show/hide or visually indicate which workspace has no windows currently in it in sketchybar or similar softwares.

Example from the AeroSpace Goodness section in the readme:
aerospace.toml

exec-on-workspace-change = ['/bin/bash', '-c',
    '/opt/homebrew/opt/sketchybar/bin/sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE EMPTY_WORKSPACES=$AEROSPACE_EMPTY_WORKSPACES'
]

.config/sketchybar/plugins/aerospace.sh

#!/usr/bin/env bash

# make sure it's executable with:
# chmod +x ~/.config/sketchybar/plugins/aerospace.sh

#!/usr/bin/env bash

# make sure it's executable with:
# chmod +x ~/.config/sketchybar/plugins/aerospace.sh

if echo "$EMPTY_WORKSPACES" | grep -q "$1"; then
	LABEL_COLOR="$RED" # marks empty workspaces in red
else
	LABEL_COLOR="$WHITE" # marks workspaces with windows in white
fi

if [ "$1" = "$FOCUSED_WORKSPACE" ]; then
    sketchybar --set $NAME background.drawing=on label.color="$LABEL_COLOR"
else
    sketchybar --set $NAME background.drawing=off label.color="$LABEL_COLOR"
fi

Currently, if adding EMPTY_WORKSPACES=$(aerospace list-workspaces --monitor focused --empty) to ~/.config/sketchybar/plugins/aerospace.sh it is slow, because it computes it for every workspace on workspace change, which is not ideal and the performance drop is visible. I could not find other way to do it dynamically so it updates if the workspace becomes empty/popuplated. I've red to readmes many times, looked at other configs in github for a way to do it with no luck.

Checklist

aerospace CLI client version: 0.14.2-Beta 0cb8dbdfc5ee73b8cbc200f175f467ebead55201
AeroSpace.app server version: 0.14.1-Beta 5861e85b65cb7dc914a0a68027c56e2bc90510fd
@nikitabobko
Copy link
Owner

nikitabobko commented Sep 2, 2024

Merging this issue with #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants