mirror of
https://github.com/SinTan1729/random.git
synced 2024-12-27 05:28:37 -06:00
Modifed to better work with crontab
This commit is contained in:
parent
8fb98d64d3
commit
ac7c4bfbe9
2 changed files with 42 additions and 15 deletions
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# This is a script to set my external monitor's brightness
|
|
||||||
# to high (70%) or low (40%) easily. It uses ddcutil to access
|
|
||||||
# the monitor's settings. When used in conjunction with heliocron,
|
|
||||||
# it can manage the monitor brightness based on sunrise or sunset,
|
|
||||||
# which can be useful if you like to work in natural light.
|
|
||||||
|
|
||||||
if [ $1 == "high" ]; then
|
|
||||||
ddcutil setvcp 10 70 && echo "Monitor brightness set to 70%"
|
|
||||||
elif [ $1 == "low" ]; then
|
|
||||||
ddcutil setvcp 10 40 && echo "Monitor brightness set to 40%"
|
|
||||||
else
|
|
||||||
echo "Please pass high/low"
|
|
||||||
fi
|
|
42
brightness-by-daylight.sh
Normal file
42
brightness-by-daylight.sh
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# This is a script to set my external monitor's brightness
|
||||||
|
# to high (70%) or low (40%) automatically according to day/night.
|
||||||
|
# It uses ddcutil to access the monitor's settings and sunwait to know
|
||||||
|
# if it's day or night. It expects a file in the following format in
|
||||||
|
# the .config directory (the values should be according to location)
|
||||||
|
|
||||||
|
# ~/.config/latlong.toml
|
||||||
|
# latitude="0.000000N"
|
||||||
|
# longitude="0.000000E"
|
||||||
|
|
||||||
|
# Add the following to crontab to make it run automatically and properly
|
||||||
|
|
||||||
|
# @reboot <location-of-this-script>
|
||||||
|
# 0 0,12 * * * <location-of-this-script> crontab
|
||||||
|
|
||||||
|
confdir="/home/sintan/.config"
|
||||||
|
|
||||||
|
if test -f $confdir/latlong.toml ; then
|
||||||
|
source $confdir/latlong.toml
|
||||||
|
else
|
||||||
|
echo "No location config found!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if called by crontab. If yes, start waiting, otherwise
|
||||||
|
# adjust brightness immediately
|
||||||
|
if [ "$1" == "crontab" ]; then
|
||||||
|
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
|
||||||
|
else
|
||||||
|
if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then
|
||||||
|
ddcutil setvcp 10 70
|
||||||
|
echo "Monitor brightness set to 70%, since it's day time."
|
||||||
|
else
|
||||||
|
ddcutil setvcp 10 40
|
||||||
|
"Monitor brightness set to 40%, since it's night time."
|
||||||
|
fi
|
||||||
|
fi
|
Loading…
Reference in a new issue