day 959 B

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