Closed C4Wiz closed 6 years ago
Use ANSI escape codes to change the text in the middle of the printed string.
See https://github.com/matryer/bitbar-plugins/blob/master/Tutorial/ansi.sh
This example picks a random colour (red/green) for the random number that comes after "Update:"
#!/usr/bin/env php
<?php
$GREEN = "\033[32m";
$RED = "\033[31m";
$BLACK = "\033[0m";
$COLOUR = (rand(0,1)) ? $RED : $GREEN;
printf("Update: $COLOUR%s", rand(0,10)) . "$BLACK| ansi=true color=black";
i thank you for your responce, but again no idea what you mean.
Please remove your code, put it in a pastebin
i thank you for your responce, but again no idea what you mean. here is my complete code
Your task is to figure out how the Tutorial and my simple example work. 🔰 💯
I'm happy to help/guide you, but I won't do it for you :)
Ask specific questions and I will explain to you the answer.
@gingerbeardman i think im close but i get a syntax error on this line: if not versions['core_current'] == versions[core_latest']:
print("Core: %s (%s)" % (versions['core_current'],
versions['core_branch'])) + "| color=black"
if not versions['core_current'] == versions[core_latest']:
print("Update available: %s" % versions['core_latest']) + "| color=red"
else:
print("Up to date| color=green")
i actually figured it out!
print("Core: %s (%s)" % (versions['core_current'],
versions['core_branch'])) + "| color=black"
if versions['core_current'] != versions['core_latest']:
print("Update available: %s" % versions['core_latest']) + "| color=red"
else:
print("Up to date| color=green")
here is my code it returns true or false, how do i make it so if it returns true it's one color, and if it returns false it's another, but keep the Update text black?
print("Update: %s" % versions['core_update']) + "| color=black"