1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-27 05:28:37 -06:00

Improved reboot behavior

This commit is contained in:
Sayantan Santra 2022-06-26 21:53:58 -05:00
parent ac7c4bfbe9
commit 46d64aebaa

View file

@ -12,7 +12,7 @@
# Add the following to crontab to make it run automatically and properly # Add the following to crontab to make it run automatically and properly
# @reboot <location-of-this-script> # @reboot <location-of-this-script> && <location-of-this-script> crontab
# 0 0,12 * * * <location-of-this-script> crontab # 0 0,12 * * * <location-of-this-script> crontab
confdir="/home/sintan/.config" confdir="/home/sintan/.config"
@ -21,15 +21,23 @@ if test -f $confdir/latlong.toml ; then
source $confdir/latlong.toml source $confdir/latlong.toml
else else
echo "No location config found!" echo "No location config found!"
exit
fi fi
# Check if called by crontab. If yes, start waiting, otherwise # Check if called by crontab as routine. If yes, start waiting,
# adjust brightness immediately # otherwise adjust brightness immediately
if [ "$1" == "crontab" ]; then if [ "$1" == "crontab" ]; then
if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then if test -f /tmp/brightness-crontab; then
sunwait wait set offset 10 $latitude $longitude && ddcutil setvcp 10 40 exit
else else
sunwait wait rise offset 10 $latitude $longitude && ddcutil setvcp 10 70 touch /tmp/brightness-crontab
if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then
sunwait wait set offset 10 $latitude $longitude && ddcutil setvcp 10 40
else
sunwait wait rise offset 10 $latitude $longitude && ddcutil setvcp 10 70
fi
rm /tmp/brightness-crontab
fi fi
else else
if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then
@ -37,6 +45,6 @@ else
echo "Monitor brightness set to 70%, since it's day time." echo "Monitor brightness set to 70%, since it's day time."
else else
ddcutil setvcp 10 40 ddcutil setvcp 10 40
"Monitor brightness set to 40%, since it's night time." echo "Monitor brightness set to 40%, since it's night time."
fi fi
fi fi