day 923 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 ]" >&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. else
  44. echo "$(basename $0) [ start | end ]" >&2
  45. exit 1
  46. fi