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

Use at instead of cron

This commit is contained in:
Sayantan Santra 2022-07-10 21:56:21 -05:00
parent 8b3eb8aa1d
commit 4b59864dde

View file

@ -9,18 +9,13 @@
# ~/.config/latlong.toml # ~/.config/latlong.toml
# latitude="0.000000N" # latitude="0.000000N"
# longitude="0.000000E" # longitude="0.000000E"
# scriptdir=<location-of-this-script>
# Add the following to crontab to make it run automatically and properly # Just run this script one manually to set it up to run perpetually (hopefully) using 'at'
# (Some distros don't come with 'at' preinstalled, so you might need to install 'at' and enable the 'atd' service.)
# @reboot <location-of-this-script> crontab
# 0 0,12 * * * <location-of-this-script> crontab
# It might also be a good idea to add this script's location to your DE's autostart list, or to '.profile' so that it launches on system login # It might also be a good idea to add this script's location to your DE's autostart list, or to '.profile' so that it launches on system login
# (Sometimes I forget to turn on the monitor when I start my PC, so this is better than having a crontab)
# To run this script whenever and HDMI cable is connected, copy this file to /usr/local/bin/ and run 'chmod +x /usr/local/bin/brightness-by-daylight.sh'
# Then create the file /etc/udev/rules.d/89-hdmi_brightness.rules with the following content :
# KERNEL=="card0", SUBSYSTEM=="drm", ACTION=="add", RUN+="/usr/local/bin/brightness-by-daylight.sh"
# Then run 'udevadm control --reload-rules' and reboot
confdir="/home/sintan/.config" confdir="/home/sintan/.config"
@ -35,17 +30,10 @@ fi
# otherwise adjust brightness immediately # otherwise adjust brightness immediately
if [ "$1" == "crontab" ]; then if [ "$1" == "crontab" ]; then
if test -f /tmp/brightness-crontab; then
exit
else
if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then if [ $(sunwait poll $latitude $longitude) == "DAY" ]; then
echo "Waiting for sunset at" $(sunwait report 35.221050N 97.445938W | grep "Daylight:" | awk '{print $6}') > /tmp/brightness-crontab at -m $(sunwait report 35.221050N 97.445938W | grep "Daylight:" | awk '{print $6}') <<< "ddcutil setvcp 10 40 && $scriptdir/brightness-by-daylight.sh crontab"
sunwait wait set offset 10 $latitude $longitude && ddcutil setvcp 10 40
else else
echo "Waiting for sunrise at" $(sunwait report 35.221050N 97.445938W | grep "Daylight:" | awk '{print $4}') > /tmp/brightness-crontab at -m $(sunwait report 35.221050N 97.445938W | grep "Daylight:" | awk '{print $4}') <<< "ddcutil setvcp 10 70 && $scriptdir/brightness-by-daylight.sh crontab"
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