#!/bin/bash # Get current monitor brightness for waybar MONITOR_SERIAL="6L1M413" VCP_CODE=10 # Get current brightness current_output=$(ddcutil getvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" 2>/dev/null) if [ $? -ne 0 ]; then echo '{"text": "N/A", "tooltip": "Monitor not available"}' exit 0 fi # Parse current brightness current=$(echo "$current_output" | grep -oP 'current value\s*=\s*\K\d+') if [ -z "$current" ]; then echo '{"text": "N/A", "tooltip": "Could not read brightness"}' exit 0 fi # Output JSON for waybar echo "{\"text\": \"$current%\", \"tooltip\": \"Monitor Brightness: $current%\"}"