dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 79ec416e415b5f98c5a8a614b3602838d4745484
parent b29d81ae5f0284838317b3ca710f8854c7583cec
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Tue, 16 Jan 2018 21:18:42 -0500

Crontab-related improvements

Diffstat:
M.config/cron/crontab | 8+++-----
M.config/cron/vdirsyncer.sh | 2++
A.config/cron/weather.sh | 12++++++++++++
M.config/forecastio/weather.py | 16++++------------
M.local/bin/my-init | 6++++++
M.xsession | 2++
6 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/.config/cron/crontab b/.config/cron/crontab @@ -20,9 +20,7 @@ # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command -LANG=en_US.utf8 -DISPLAY=:0.0 -*/5 * * * * cd /home/djmoch/.config/forecastio && ./weather.py -*/15 * * * * ~/.config/cron/vdirsyncer.sh > ~/.local/var/log/vdirsyncer 2>&1 -*/15 * * * * ~/.config/cron/photosync.sh > ~/.local/var/log/photosync 2>&1 +*/5 * * * * $HOME/.config/cron/weather.sh > $HOME/.local/var/log/weather 2>&1 +*/15 * * * * $HOME/.config/cron/vdirsyncer.sh > $HOME/.local/var/log/vdirsyncer 2>&1 +*/15 * * * * $HOME/.config/cron/photosync.sh > $HOME/.local/var/log/photosync 2>&1 diff --git a/.config/cron/vdirsyncer.sh b/.config/cron/vdirsyncer.sh @@ -1,4 +1,6 @@ #!/bin/sh echo "Beginning sync on `date`" +export DISPLAY=`cat $HOME/.xdisplay` vdirsyncer sync +unset DISPLAY echo "Completed sync on `date`" diff --git a/.config/cron/weather.sh b/.config/cron/weather.sh @@ -0,0 +1,12 @@ +#!/bin/sh +if ping -c 1 ipinfo.io > /dev/null 2>&1 +then + echo "ipinfo reachable. Proceeding." +else + echo "ipinfo NOT reachable. Aborting." + exit 1 +fi + +cd "$HOME/.config/forecastio/" + +./weather.py diff --git a/.config/forecastio/weather.py b/.config/forecastio/weather.py @@ -33,20 +33,12 @@ def generate_forecast(): outfile.write(temp + ", " + str(current_temp.summary) + ", " + high +"/"+low + " F") except requests.packages.urllib3.exceptions.NewConnectionError: error = True - if DEBUG: - sys.stdout.writelines(datetime.now().strftime("%m/%d/%Y %I:%M:%S:") + " Could not connect. Will try again \ - in 5 minutes.\n") + sys.stdout.writelines(datetime.now().strftime("%m/%d/%Y %I:%M:%S:") + " Could not connect. Will try again \ + in 5 minutes.\n") - if DEBUG and not error: + if not error: sys.stdout.writelines(datetime.now().strftime("%m/%d/%Y %I:%M:%S:") + " Successfully updated weather\n") if __name__ == '__main__': - try: - if environ['DEBUG']: - DEBUG = True - except KeyError: - DEBUG = False - - if DEBUG: - sys.stdout.writelines(datetime.now().strftime("%m/%d/%Y %I:%M:%S:") + " Updating weather\n") + sys.stdout.writelines(datetime.now().strftime("%m/%d/%Y %I:%M:%S:") + " Updating weather\n") generate_forecast() diff --git a/.local/bin/my-init b/.local/bin/my-init @@ -33,6 +33,7 @@ then rm -rf "$HOME/.terminfo" rm -rf "$vim_bundle_path" rm "$HOME/.less" + type crontab > /dev/null 2>&1 && crontab -r fi # Terminfo @@ -94,4 +95,9 @@ then chmod 000 "$HOME/._.djmoch" fi +if __has "crontab" +then + cat "$HOME/.config/cron/crontab" | crontab - +fi + unset __clone __has diff --git a/.xsession b/.xsession @@ -3,6 +3,8 @@ # ~/.xsession # +[ -n "$DISPLAY" ] && echo "$DISPLAY" > "$HOME/.xdisplay" + if [ -d /usr/share/fonts/noto/ ] then xset fp+ /usr/share/fonts/noto/