dotfiles

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

commit bdd8ad77f82a855e9ae37f9fdfb2192590177861
parent 111aec0bc5d92639ee34b615dcbd38b50cf78f2b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 11 Feb 2018 18:16:29 -0500

Use 'my' for smarter crontabbing

Diffstat:
M.local/bin/my | 60+++++++++++++++++++++++++++++++++++++++---------------------
M.local/bin/my-init | 19+++++++++----------
M.profile | 2++
M.shrc | 1-
4 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/.local/bin/my b/.local/bin/my @@ -7,7 +7,7 @@ # have one handler, but exist to avoid re-writes across my dotfiles # later on. -[ $# -eq 0 -o -z "$DISPLAY" ] && exit 1 +[ $# -eq 0 ] && exit 1 log="$HOME/.local/var/log/my" command=$1 @@ -160,7 +160,6 @@ case $command in xrandr_options=`xrandr -q | grep ' disconnected' | awk '{print $1}'` for option in $xrandr_options do - __mylog "my screen" "Executing xrandr --output $option --off" xrandr --output $option --off done @@ -168,7 +167,6 @@ case $command in numoptions=`echo $xrandr_options | wc -w` if [ $numoptions -eq 1 ] then - __mylog "my screen" "Executing xrandr --output $xrandr_options --auto --primary" xrandr --output $xrandr_options --auto --primary else # Prefer external monitors @@ -182,12 +180,11 @@ case $command in [ -n "$primary_found" ] && selection=$option && break done - __mylog "my screen" "Executing xrandr --output $selection --auto --primary" xrandr --output $selection --auto --primary for option in $xrandr_options do - [ $option != $selection ] && __mylog "my screen" "Executing xrandr --output $option --off" && xrandr --output $option --off + [ $option != $selection ] && xrandr --output $option --off done fi exec my wallpaper @@ -319,23 +316,9 @@ case $command in dotfiles) predicate="$1" && shift case $predicate in - age) - current=`date '+%s'` - dotdate=`date -r $HOME/._.djmoch '+%s'` - if [ $? -ne 0 ] - then - __mylog "my dofiles: Dotfile config not initialized" - exit 1 - fi - echo "$current - $dotdate" | bc - ;; check) - age=`my dotfiles age` - if [ $age -gt 604800 ] - then - echo "Dotfiles more than one week old" - exit 1 - fi + cd "$HOME" + find . -maxdepth 1 -name ._.djmoch -mtime +8 -exec echo "Dotfiles more than one week old" \; ;; update) if [ -d "$HOME/.dotfiles" ] @@ -362,4 +345,39 @@ case $command in ;; esac ;; + cron) + case ":$PATH:" in + *:"$HOME/.local/bin":*) ;; + *) PATH="$HOME/.local/bin:$PATH" ;; + esac + cronpath="$HOME/.local/lib/cron" + logpath="$HOME/.local/var/log" + for job in $cronpath/* + do + [ -f $job -a -x $job ] && $job > $logpath/`basename $job` + done + ;; + login_async) + starttime=`date '+%s'` + current=`date '+%s'` + while [ `echo "$current - $starttime" | bc` -le 120 ] + do + if ping -c 1 danielmoch.com > /dev/null 2>&1 + then + connected=1 + break + fi + sleep 1 + current=`date '+%s'` + done + if [ -n "$connected" ] + then + cd "$HOME" + find . -maxdepth 1 -name ._.djmoch -mtime +8 -exec my dotfiles update \; + fi + ;; + login) + my login_async & + ;; + *) echo "my: command $command not found" >&2 esac diff --git a/.local/bin/my-init b/.local/bin/my-init @@ -61,6 +61,7 @@ __optclone_pathogen() echo "Succeeded" ;; esac + rm /tmp/vimpackages.$$ } @@ -71,7 +72,6 @@ then rm -rf "$HOME/.terminfo" rm -rf "$vim_bundle_path" rm "$HOME/.less" - type crontab > /dev/null 2>&1 && echo -n " " && crontab -r fi if [ -f "$HOME/._.djmoch" ] @@ -102,18 +102,17 @@ fi if __has "crontab" && [ -n "$crontab_init" ] then echo " Installing crontab" - cron_dir="$HOME/.local/lib/cron" - log_dir="$HOME/.local/var/log" - cat > /tmp/crontab.$$ <<-EOF -# m h dom mon dow command -*/5 * * * * $cron_dir/weather.sh > $log_dir/weather 2>&1 -*/15 * * * * PATH="$HOME/.local/bin":$PATH $cron_dir/vdirsyncer.sh > $log_dir/vdirsyncer 2>&1 -*/15 * * * * $cron_dir/photosync.sh > $log_dir/photosync 2>&1 - + localbin="$HOME/.local/bin" + crontab -l > /tmp/crontab.$$.orig + [ $? -ne 0 ] && echo "" > /tmp/crontab.$$.orig + cat >> /tmp/crontab.$$ <<-EOF +*/15 * * * * "\$HOME/.local/bin/my" cron EOF + cat /tmp/crontab.$$.orig >> /tmp/crontab.$$ cat /tmp/crontab.$$ | crontab rm /tmp/crontab.$$ - unset cron_dir log_dir + rm /tmp/crontab.$$.orig + unset localbin fi # Vim plugins diff --git a/.profile b/.profile @@ -63,3 +63,5 @@ if type my-init > /dev/null 2>&1 && [ ! -f "$HOME/._.djmoch" ] then my-init fi + +my login diff --git a/.shrc b/.shrc @@ -79,5 +79,4 @@ then then [ $SHLVL -le 1 ] && cat /etc/motd fi - my dotfiles check fi