24 lines
565 B
Bash
Executable File
24 lines
565 B
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
CMD="brightnessctl set"
|
|
STATUS=$(brightnessctl g)
|
|
MAX=$(brightnessctl m)
|
|
CURRENT=$(echo "scale=2; $STATUS / $MAX" | bc)
|
|
|
|
if [ $1 = 'd' ]; then
|
|
# Using bc to perform floating-point comparison
|
|
if (( $(echo "$CURRENT <= 0.05" | bc -l) )); then
|
|
bash -c "$CMD 1"
|
|
elif (( $(echo "$CURRENT <= 0.1" | bc -l) )); then
|
|
bash -c "$CMD 2%-"
|
|
else
|
|
bash -c "$CMD 5%-"
|
|
fi
|
|
elif [ $1 = 'u' ]; then
|
|
if (( $(echo "$CURRENT < 0.1" | bc -l) )); then
|
|
bash -c "$CMD +2%"
|
|
else
|
|
bash -c "$CMD +5%"
|
|
fi
|
|
fi
|