Skip to content

Instantly share code, notes, and snippets.

@fsmithred
Created May 25, 2017 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fsmithred/7d0722131bfedd5457c6e70ba6585327 to your computer and use it in GitHub Desktop.
Save fsmithred/7d0722131bfedd5457c6e70ba6585327 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# redshifty
# run one-shot redshift with desired settings
LOGFILE="/tmp/redshifty.log"
# set limits here.
MINT="3800"
MAXT="7800"
MINB="0.20"
MAXB="1.00"
temp0=$(cut -d" " -f1 "$LOGFILE")
bright0=$(cut -d" " -f2 "$LOGFILE")
settings=$(yad --form --field=Temp:NUM --field=Bright:NUM \
"$temp0!$MINT..$MAXT!100" "$bright0!0.20..1.00!0.05!2" \
--title redshifty --separator=" " \
--text="Set Temp between $MINT and $MAXT\nSet Bright between $MINB and $MAXB \n")
ret="$?"
if [[ $ret -eq 1 ]] ; then
exit 0
fi
echo "$settings" > "$LOGFILE"
temp=$(echo $settings | cut -d" " -f1)
bright=$(echo $settings | cut -d" " -f2)
if [[ "$temp" -lt "$MINT" ]] ; then
TEMP="$MINT"
elif [[ "$temp" -gt "$MAXT" ]] ; then
TEMP="$MAXT"
else
TEMP="$temp"
fi
if [[ "$bright" < "$MINB" ]] ; then
BRIGHT="$MINB"
elif [[ "$bright" > "$MAXB" ]] ; then
BRIGHT="$MAXB"
else
BRIGHT="$bright"
fi
redshift -O "$TEMP" -b "$BRIGHT"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment