| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | #!/bin/bash# Brightness slider for external monitor using ddcutil# Monitor configurationMONITOR_SERIAL="6L1M413"VCP_CODE=10# Get current brightness (VCP code 10)current_output=$(ddcutil getvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" 2>/dev/null)if [ $? -ne 0 ] || [ -z "$current_output" ]; then    echo "Error: Could not communicate with monitor $MONITOR_SERIAL" >&2    exit 1fi# Parse current brightness from output like "VCP code 0x10 (Brightness): current value = 50, max value = 100"current_percent=$(echo "$current_output" | grep -oP 'current value\s*=\s*\K\d+')if [ -z "$current_percent" ]; then    echo "Error: Could not parse brightness value" >&2    exit 1fi# Round to nearest 5current_percent=$(((current_percent + 2) / 5 * 5))# Generate brightness levelslevels=""for i in {0..100..5}; do    if [ "$i" -eq "$current_percent" ]; then        levels+="● $i%\n"    else        levels+="  $i%\n"    fidone# Show menu and get selectionselected=$(echo -e "$levels" | bemenu -l 15 -p " Monitor Brightness" --counter always -c -W 0.2 -B 10 \    --fixed-height --fn 'B612 11' \    --bdr "#323232" --tf "#FFFFFF" --hf "#FFFFFF")# Exit if nothing selectedif [ -z "$selected" ]; then    exit 0fi# Extract percentage from selectionpercent=$(echo "$selected" | grep -oP '\d+(?=%)')# Set brightnessif [ -n "$percent" ]; then    ddcutil setvcp --sn "$MONITOR_SERIAL" "$VCP_CODE" "$percent"fi
 |