Update fzf location
[dotfiles] / .bash_pomodoro
1 #!/bin/bash
2 # POMODORO in YA TerMINAL ;)
3
4 function pomo {
5 RED='\033[0;31m'
6 NC='\033[0m' # No Color
7 ORANGE='\033[0;33m'
8 printf "${ORANGE}POMODORO in YA TERMINAL${NC}\n"
9
10 if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
11 echo "usage: pomo 25 minute cycle"
12 echo -e " or: pomo [break]['_message_'] see options below\n"
13 echo "Options:"
14 echo " d: timer duration in minutes"
15 echo " s: 05 minute break"
16 echo " l: 15 minute break"
17 echo " message: Your message to display"
18 return
19 fi
20
21 if [[ "$1" == "-v" ]] || [[ "$1" == "--version" ]]; then
22 echo -e "${ORANGE}POMODORO TIMER BY RUKY"
23 echo " v: 1"
24 echo " twitter: @justruky"
25 echo " blog: rukshn.github.io"
26 echo -e " email: arkruka[@]gmail.com"
27 return
28 fi
29
30 TITLE="POMODORO TIMER"
31 ICON="face-cool"
32 BEEP="_alarm 400 200"
33 TIMER=1500
34
35 while :
36 do
37 case "$1" in
38 -d | --duration)
39 TIMER=$(($2*60))
40 shift 2
41 ;;
42 -l | --long-break)
43 MESSAGE="Long break over, back to work"
44 TIMER=900
45 shift
46 ;;
47 -s | --short-break)
48 MESSAGE="Short break over, back to work"
49 TIMER=300
50 shift
51 ;;
52 -*)
53 echo "Error: Unknown option: $1" >&2
54 return 1
55 ;;
56 *) # No more options
57 break
58 ;;
59 esac
60 done
61
62 if [ -n "$1" ]; then
63 MESSAGE="$1"
64 elif [ -z "$MESSAGE" ]; then
65 MESSAGE="Time to take a break"
66 fi
67
68 echo -e "${RED}TIMER SET FOR $(($TIMER/60)) MINUTES"
69
70 # LINUX users
71 if [[ "$(uname)" == "Linux" ]]; then
72 eval "(sleep $TIMER && notify-send '$TITLE' '$MESSAGE' --icon=$ICON && $BEEP &)"
73 # MAC users
74 elif [[ "$(uname)" == "Darwin" ]]; then
75 eval "(sleep $TIMER && terminal-notifier -message '$MESSAGE' -title 'Pomodoro' --subtitle '$TITLE' && $BEEP &)"
76 else
77 echo "Sorry! Only Linux or Mac";
78 fi
79 }
80
81 _alarm() {
82 if [[ "$(uname)" == "Linux" ]]; then
83 paplay notification.ogg
84 elif [[ "$(uname)" == "Darwin" ]]; then
85 say -v bells 'beep'
86 fi
87 }