Created
November 6, 2023 15:24
-
-
Save naranyala/5d4ca0c7e76bac290468f9689e7614d3 to your computer and use it in GitHub Desktop.
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 | |
# redshift-selector.sh | |
# Generates a list of color temperature labels for selection | |
generate_menu() { | |
echo "Very High" | |
echo "High" | |
echo "Medium" | |
echo "Low" | |
echo "Very Low" | |
} | |
# Maps the selected label to a color temperature and sets it | |
set_temperature() { | |
local label=$1 | |
local temp | |
case $label in | |
"Very High") temp=10000 ;; | |
"High") temp=7500 ;; | |
"Medium") temp=5500 ;; | |
"Low") temp=3700 ;; | |
"Very Low") temp=1900 ;; | |
*) echo "Invalid selection"; exit 1 ;; | |
esac | |
redshift -O "$temp" | |
} | |
# This function integrates with Rofi | |
rofi_menu() { | |
generate_menu | rofi -dmenu -p "Redshift Temperature:" -lines 5 -width 25 | |
} | |
# Reset the color temperature to default | |
reset_temperature() { | |
redshift -x | |
} | |
# Main logic | |
selection=$(rofi_menu) | |
if [ -n "$selection" ]; then | |
reset_temperature | |
set_temperature "$selection" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment