matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.56k stars 643 forks source link

Add support for multiple colors in menubar output. #737

Closed SxC97 closed 3 years ago

SxC97 commented 3 years ago

I am the author of the Yabai-Spaces. The colorized output (examples here) worked on both BitBar and currently on Swiftbar.

I would like the plugin to work on xBar too but it seems like xterm-256 colors are not supported on xbar.

Is this feature on the roadmap? If not, is there any other way to get multiple colors in the output?

leaanthony commented 3 years ago

ANSI codes are indeed supported. I'm sure the 256 standard is supported too. If not, it would be easy to add it 👍

SxC97 commented 3 years ago

Oops, my bad then 😅!

The plugin uses the following code to specify colors:

BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
WHITE='\033[0;37m'

The output in the terminal and in Swiftbar is accurate:

1 2 3 4 5 6 7 8 | ansi=true, where 5 is red and the rest of the text is blue

But in xbar the output looks like this:

[34m, the rest of the output doesn’t print and the text is just white.

I’ve tried some of the other ways to color the output from #467 like using \e, \u100b, \x1b, and \0x1b but I can’t seem to get it to print correctly.

Do you have a snippet of code of this feature working properly that I can test my code against? Thank You!

leaanthony commented 3 years ago

Support was added via last PR (https://github.com/matryer/xbar/pull/703) so perhaps it hadn't made it's way out yet in the form of a release yet. Running what's on main will work though. This is the plugin I use for testing: https://gist.github.com/leaanthony/ed6ec2d9f3dcfbf3056cb02bda7570ce - let me know if I can be of further help. Cheers.

SxC97 commented 3 years ago

Ah, I guess I missed that PR. I’ll try running the latest version later today. Thank You!