Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions xfce4-night-mode-redshift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,37 @@
# https://gitlab.com/bimlas/xfce4-night-mode (main repository)
# https://github.com/bimlas/xfce4-night-mode (mirror, please star if you like the plugin)

if ( LC_ALL='C' redshift -p 2> /dev/null | grep 'Period: Night' > /dev/null ); then
mode='night'
else
mode='day'
fi
# Change this variable to define which mode to use while RedShift transitions from day to night or vice versa
# Choices: night|day
TRANSITION_MODE='night'

redshift_period=$( LC_ALL='C' redshift -p 2> /dev/null | grep -E '^Period: ' | grep -Eo '(Transition|Night|Day)' )

case $redshift_period in
"Day")
mode='day'
;;

"Night")
mode='night'
;;

"Transition")
if [ $TRANSITION_MODE ]; then
if [[ $TRANSITION_MODE =~ (day|night) ]]; then
mode=$TRANSITION_MODE
else
echo 'Invalid value set for $TRANSITION_MODE!'
fi
else
echo 'RedShift transition period detected but $TRANSITION_MODE is not set. Set $TRANSITION_MODE to define which mode to use during transition periods.'
fi
;;

*)
echo "Could not determine RedShift period: $redshift_period"
;;
esac

"$(dirname "$0")/xfce4-night-mode.sh" "$mode" | sed '/<tool>/,/<\/tool>/ d'
echo '<tool>
Expand Down