SwiftBar icon indicating copy to clipboard operation
SwiftBar copied to clipboard

Text color issue

Open C4Wiz opened this issue 1 month ago • 6 comments

i am trying to make text white vs grey, i tried everything and it stays grey, see attached screenshot:

Image

C4Wiz avatar Nov 15 '25 17:11 C4Wiz

@C4Wiz can you send an example of your stdout that produces this menu?

I think this could be because any menu item that has no action attached will have a disabled state, the colour might be overridden.

andyearnshaw avatar Nov 17 '25 12:11 andyearnshaw

@C4Wiz can you send an example of your stdout that produces this menu?

I think this could be because any menu item that has no action attached will have a disabled state, the colour might be overridden.

Extract and format values

version_line = "Firmware: " + str(info.get("version", ""))
hashrate_gh = info.get("hashRate", 0)
hashrate_th = hashrate_gh / 1000.0
hashrate_line = "Hashrate: " + str(round(hashrate_th, 2)) + " TH/s"
temp_line = "Asic Temp: " + str(info.get("temp", 0)) + "°C"
vr_temp_line = "VR Temp: " + str(info.get("vrTemp", 0)) + "°C"
fanspeed_line = "Fan: " + str(info.get("fanspeed", 0)) + "%"
power_line = "Power: " + str(round(info.get("power", 0), 1)) + "W"
voltage = info.get("voltage", 0)
voltage_line = "Voltage: " + str(round(voltage/1000, 2)) + "V"
best_diff_line = "Best Difficulty: " + str(info.get("bestDiff", ""))
best_session_line = "Best Session: " + str(info.get("bestSessionDiff", ""))
shares_accepted_line = "Shares Accepted: " + str(info.get("sharesAccepted", 0))
shares_rejected = info.get("sharesRejected", 0)
shares_rejected_line = "Shares Rejected: " + str(shares_rejected) if shares_rejected > 0 else ""

Print stats

print(version_line)
if uptime_line:
    print(uptime_line)
print(hashrate_line)
print(temp_line)
print(vr_temp_line)
print(fanspeed_line)
print(power_line)
print(voltage_line)
print(best_diff_line)
print(best_session_line)
print(shares_accepted_line)
if shares_rejected_line:
    print(shares_rejected_line)

C4Wiz avatar Nov 17 '25 13:11 C4Wiz

@C4Wiz I don't see the colour information in there. If ending a line with | color=red doesn't give you red text, you might need to add an action, e.g. | color=red refresh=true

andyearnshaw avatar Nov 17 '25 14:11 andyearnshaw

added that and it does fix the color, seems like a workaround though

C4Wiz avatar Nov 17 '25 14:11 C4Wiz

Yeah, it is a bit of a workaround and possibly not quite the best experience (since you don't want the hover/click action, etc). As far as I understand it, this is a limitation set by the operating system and the only way to work around it would be to recreate the NSMenuItem styling using a custom view, which is less straightforward than it sounds, I think. @melonamin might have better insight than me, though.

andyearnshaw avatar Nov 17 '25 17:11 andyearnshaw

Yep, @andyearnshaw got it completely correct - if we have no action associated with the menu item, it is shown as disabled. The only way to fix this is to associate a dummy action or set refresh=true.

I feel pretty strongly against doing custom styling; the number of edge cases and support burden will explode.

melonamin avatar Nov 18 '25 18:11 melonamin