day 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. cd
  3. XSESS=1
  4. SSH_TIME=${SSH_TIME:-3h}
  5. START_EMACS=${START_EMACS:-1}
  6. if [ -x "${DISPLAY}" ] ; then
  7. XSESS=0
  8. fi
  9. if [ $# -lt 1 ] ; then
  10. echo "$(basename $0) [ start | end | mid ]" >&2
  11. exit 1
  12. fi
  13. check_ssh() {
  14. ssh-add -l >/dev/null
  15. SSH_ADDED=$?
  16. if [ $SSH_ADDED != 0 ] ; then
  17. ssh-add -t ${SSH_TIME}
  18. fi
  19. }
  20. start_emacs() {
  21. if [ $START_EMACS -eq 1 ] ; then
  22. i3-run i3-workspace-layout emacs-here '"1: emacs"'
  23. fi
  24. }
  25. notify() {
  26. send-notification "$1" "$2"
  27. }
  28. restart_i3() {
  29. if [ $XSESS -eq 1 ] ; then
  30. i3-msg restart
  31. fi
  32. }
  33. if [ $1 == "start" ] ; then
  34. check_ssh
  35. sync-dirs . School Projects
  36. restart_i3
  37. start_emacs
  38. notify "Starting Day" "On $(hostname -s)."
  39. elif [ $1 == "end" ] ; then
  40. check_ssh
  41. sync-dirs . School Projects
  42. notify "Ending Day" "On $(hostname -s)."
  43. elif [ $1 == "mid" ] ; then
  44. check_ssh
  45. sync-dirs org .emacs.d School
  46. notify "Mid Day Sync" "On $(hostname -s)."
  47. else
  48. echo "$(basename $0) [ start | end ]" >&2
  49. exit 1
  50. fi