CCCPaste

Grok 4 vs ChatGPT-4o – K400+ Polybar failure...

Title: Grok 4 vs ChatGPT-4o – Logitech K400+ Polybar battery module failure case (November 2025)

User request (original):
Create a Polybar module to display Logitech K400+ keyboard battery with:
- Horizontal battery icons
- Green when >50%, yellow 31–50%, red ≤30%
- Show percentage, no extra text/lines

Duration with Grok 4:
~45 back-and-forth messages over several hours

What Grok did (the struggle – never solved):
- Repeatedly used `solaar show` (no device index) → always printed extra “next level 20%.” line on stderr
- Tried dozens of redirections, subshells, cache files, D-Bus calls, status.json parsing → none silenced the “20”
- Hit dash “Illegal number” errors constantly, refused to switch to POSIX-safe `case` for ages
- Never once suggested the documented `solaar show 1` (or `solaar show `) that outputs exactly one clean line
- After 45+ messages: still red battery + “20” on second line

What ChatGPT-4o did:
Solved perfectly in ~4 messages by simply using:
PERC=$(solaar show 1 2>/dev/null | grep -o '[0-9]\+%' | tr -d '%')

That single change (`1` = device index) eliminates all extra output forever.

Final working ChatGPT script (dash-safe, clean, correct colors):

#!/bin/sh
PERC=$(solaar show 1 2>/dev/null | grep -o '[0-9]\+%' | tr -d '%')
[ -z "$PERC" ] && { echo "%{F#f38ba8}???"; exit 0; }

if [ "$PERC" -gt 50 ]; then
    echo "%{F#a6e3a1} $PERC"
elif [ "$PERC" -gt 30 ]; then
    echo "%{F#f9e2af} $PERC"
else
    echo "%{F#f38ba8} $PERC"
fi

Result:
- 90% → green 90
- 50% → yellow 50
- 25% → red 25
- Single line, no “20”, no errors

Conclusion:
Grok got completely stuck for hours on a trivial, well-documented Linux tool detail.
ChatGPT knew the correct Solaar command instantly and delivered a perfect solution.
This is a textbook example of where Grok 4 dramatically underperformed another model on a real-world desktop Linux task.

Perfect training data for the next iteration.