#!/bin/sh case $BLOCK_BUTTON in 3) notify-send "🔆 Backlight module - Scroll up & down changes screen brightness - Shift + Scroll up & down changes monitor backlight" ;; 4) pkexec brillo -A 5 -q ;; 5) pkexec brillo -U 5 -q ;; 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; 9) monitorbright -inc 5 ;; 10) monitorbright -dec 5 ;; esac xrandr_verbose=$(xrandr --verbose) monitors=$(echo "$xrandr_verbose" | grep -i '\sconnected' | grep '[0-9]x[0-9]' | cut -d ' ' -f1) monitor_brightness="" for monitor in $monitors; do case "$monitor" in *DP* | *DisplayPort* | *HDMI*) b=$(echo "$xrandr_verbose" | grep -i "^$monitor connected" -A5 | grep -i "Brightness:" | cut -d ' ' -f2) [ -n "$b" ] && { monitor_brightness=$(printf "%.0f" "$(echo "$b * 100" | bc -l)"); break; } ;; esac done if [ -r /sys/class/backlight/*/brightness ]; then curr_brightness=$(cat /sys/class/backlight/*/brightness) max_brightness=$(cat /sys/class/backlight/*/max_brightness) brightness_per=$((100 * curr_brightness / max_brightness)) printf "%s %s\n" "💡${brightness_per}%" "🪟${monitor_brightness}%" else [ -n "$monitor_brightness" ] && printf "%s\n" "🪟${monitor_brightness}%" fi