Created
May 16, 2024 00:49
-
-
Save michaelmrose/22ea877de69b881fe6ea7f014b10131a to your computer and use it in GitHub Desktop.
less green assumes one monitor make executable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the initial gamma values for red, green, and blue | |
initial_gamma=$(xrandr --verbose | grep -m 1 'Gamma:' | awk '{print $2}') | |
initial_red=$(echo $initial_gamma | cut -d: -f1) | |
initial_green=$(echo $initial_gamma | cut -d: -f2) | |
initial_blue=$(echo $initial_gamma | cut -d: -f3) | |
# Define the display output, omitting the header "Monitors: 3" | |
output=$(xrandr --listmonitors | grep -v "Monitors:" | awk '{print $4}' | head -n 1) | |
# Convert initial green gamma to a float | |
initial_green=$(echo "scale=2; $initial_green" | bc) | |
# Define the decrement value (5%) | |
decrement=0.01 | |
# Run the loop until the green gamma value is reduced to a minimum threshold | |
while (( $(echo "$initial_green > 0" | bc -l) )); do | |
# Reduce the green gamma value by 5% | |
initial_green=$(echo "scale=2; $initial_green - $decrement" | bc) | |
# Ensure the green gamma value doesn't go below 0 | |
if (( $(echo "$initial_green < 0" | bc -l) )); then | |
initial_green=0 | |
fi | |
# Apply the new gamma values | |
xrandr --output $output --gamma $initial_red:$initial_green:$initial_blue | |
echo decreasing green | |
# Wait for 1 seconds | |
sleep 1 | |
done | |
echo "Green gamma reduction complete." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment