Skip to content

Commit a0cd970

Browse files
authored
Merge pull request #1 from va1entin/handle-redshift-transition-period
Handle redshift transition period
2 parents 4c6ae90 + e9b1835 commit a0cd970

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

xfce4-night-mode-redshift.sh

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,37 @@
44
# https://gitlab.com/bimlas/xfce4-night-mode (main repository)
55
# https://github.com/bimlas/xfce4-night-mode (mirror, please star if you like the plugin)
66

7-
if ( LC_ALL='C' redshift -p 2> /dev/null | grep 'Period: Night' > /dev/null ); then
8-
mode='night'
9-
else
10-
mode='day'
11-
fi
7+
# Change this variable to define which mode to use while RedShift transitions from day to night or vice versa
8+
# Choices: night|day
9+
TRANSITION_MODE='night'
10+
11+
redshift_period=$( LC_ALL='C' redshift -p 2> /dev/null | grep -E '^Period: ' | grep -Eo '(Transition|Night|Day)' )
12+
13+
case $redshift_period in
14+
"Day")
15+
mode='day'
16+
;;
17+
18+
"Night")
19+
mode='night'
20+
;;
21+
22+
"Transition")
23+
if [ $TRANSITION_MODE ]; then
24+
if [[ $TRANSITION_MODE =~ (day|night) ]]; then
25+
mode=$TRANSITION_MODE
26+
else
27+
echo 'Invalid value set for $TRANSITION_MODE!'
28+
fi
29+
else
30+
echo 'RedShift transition period detected but $TRANSITION_MODE is not set. Set $TRANSITION_MODE to define which mode to use during transition periods.'
31+
fi
32+
;;
33+
34+
*)
35+
echo "Could not determine RedShift period: $redshift_period"
36+
;;
37+
esac
1238

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

0 commit comments

Comments
 (0)