CR: Waybar CSS Performance — Implementation
Changes Applied
1. Removed box-shadow Declarations (8 instances)
GTK3 renders box-shadow entirely on CPU. Multi-line shadow stacks with alpha() compositing were the primary CPU driver.
window#waybar/* REMOVED — 5-value box-shadow stack */
box-shadow:
0 6px 20px alpha(@crust, 0.6),
0 0 30px alpha(@blue, 0.12),
0 0 60px alpha(@mauve, 0.05),
inset 0 1px 0 alpha(@surface2, 0.3);
tooltip/* REMOVED */
box-shadow: 0 4px 12px alpha(@crust, 0.5);
#custom-power:hover/* REMOVED */
box-shadow: 0 0 15px alpha(@red, 0.4);
@keyframes glow-pulse (3 frames)/* REMOVED — replaced with opacity fallback */
0% { box-shadow: 0 0 5px alpha(@blue, 0.3); }
50% { box-shadow: 0 0 15px alpha(@blue, 0.5); }
100% { box-shadow: 0 0 5px alpha(@blue, 0.3); }
@keyframes border-glow-cycle (4 frames)/* REMOVED — retained border-color only */
0% { border-color: ...; box-shadow: 0 0 8px alpha(@blue, 0.3); }
33% { border-color: ...; box-shadow: 0 0 8px alpha(@mauve, 0.3); }
66% { border-color: ...; box-shadow: 0 0 8px alpha(@teal, 0.3); }
100% { border-color: ...; box-shadow: 0 0 8px alpha(@blue, 0.3); }
2. Disabled Infinite CSS Animations (7 → 0 always-on)
Infinite animations force GTK to repaint every frame. Each repaint recalculates all box-shadow and alpha() properties.
| Selector | Animation | Action |
|---|---|---|
|
|
Commented out |
|
|
Commented out |
|
|
Commented out |
|
|
Removed |
|
|
Commented out |
| Selector | Animation | Rationale |
|---|---|---|
|
|
Only fires when a workspace is urgent (rare) |
|
|
Only fires at critical temp (emergency indicator) |
|
|
Only fires at critical battery (emergency indicator) |
3. Disabled transition: all (4 instances)
transition: all tells GTK to interpolate every CSS property on state change. With modules updating every 2-5 seconds, this triggers constant transition computation.
| Selector | Line |
|---|---|
|
96 |
|
302 |
|
495 |
|
519 |
4. Restored custom/media Module
The media module (playerctl -F) was temporarily removed during investigation to test if playerctl follow-mode caused the CPU spike. It did not. Restored to modules-center.
Future Considerations
Safe Visual Alternatives
| Removed Effect | Safe Replacement | Why |
|---|---|---|
|
|
Borders are GPU-accelerated in GTK3 |
|
|
Single-edge accent, zero CPU cost |
|
|
Only interpolates one property, not all |
Infinite |
Remove, or use conditional selectors only ( |
Conditional animations only fire on state change |
Performance Testing Procedure
Before adding visual effects to waybar CSS:
# 1. Apply CSS change
# 2. Restart waybar
kill $(pgrep -x waybar) 2>/dev/null && waybar &disown 2>/dev/null
# 3. Wait 30 seconds for startup to settle
sleep 30
# 4. Check CPU — must be <2%
top -b -n1 | awk '/waybar/ {print "CPU:", $9"%"}'
# 5. If >2%, the CSS change is too expensive — revert