Browse code

Init (for real now)

Blackbeard authored on 2018-09-12 03:21:10
Showing 2 changed files
1 1
deleted file mode 120000
... ...
@@ -1 +0,0 @@
1
-/home/queso/bin/pomodoro
2 0
\ No newline at end of file
3 1
new file mode 100755
... ...
@@ -0,0 +1,86 @@
1
+#!/bin/sh
2
+WORK_TIME=1500
3
+REST_TIME=300
4
+SOUND="/usr/share/sounds/Oxygen-Sys-Log-In.ogg"
5
+SAY_MESSAGE_STOP="Please stop aworking"
6
+SAY_MESSAGE_CONTINUE="Please stop aworking"
7
+
8
+
9
+function _pomodoro_clockWork {
10
+    local time_work="$1"
11
+    sleep "$work_time"
12
+}
13
+
14
+function _pomodoro_clockRest {
15
+    local time_rest="$1"
16
+    sleep "$time_rest"
17
+}
18
+
19
+function _pomodoro_sound {
20
+    local sound="$1"
21
+    mpv "$sound"
22
+}
23
+
24
+function _pomodoro_say {
25
+    local message="$1"
26
+    espeak "$message" 2>/dev/null
27
+}
28
+
29
+function _pomodoro_sayWork {
30
+    espeak "You can continue working now" 2>/dev/null
31
+}
32
+
33
+function _pomodoro_popup {
34
+    local message="$1"
35
+    local time_out="$2"
36
+    xmessage \
37
+    	-buttons Ok:0,"Not sure":1,Cancel:2 \
38
+	-default Ok \
39
+	-nearmouse "$message" \
40
+	-timeout "$time_out" 
41
+}
42
+
43
+function _pomodoro_popupRest {
44
+    local message="time to rest"
45
+    local time_out=300
46
+    _pomodoro_popup "$message" "$time_out"
47
+}
48
+
49
+
50
+function _pomodoro_timerWork {
51
+    _pomodoro_wait25
52
+    _pomodoro_sound
53
+    _pomodoro_sayStop
54
+    _pomodoro_popupRest
55
+    _pomodoro_sayWork
56
+}
57
+
58
+function _pomodoro_timerRest {
59
+    _pomodoro_popupRest
60
+    _pomodoro_sound
61
+    _pomodoro_sayWork
62
+}
63
+
64
+function handle_arguments {
65
+    if [ -z "$1" ]; then
66
+	_pomodoro_timerWork
67
+    else
68
+	not_empty_arguments "$@"
69
+    fi
70
+    return
71
+}
72
+
73
+function not_empty_arguments {
74
+    while [ "$1" != "" ]; do
75
+	case "$1" in
76
+	    -r | --rest )        _pomodoro_timerRest ; shift ;;
77
+	    -w | --work )        _pomodoro_timerWork ; shift ;;
78
+#	    -p | --playlist-id )    argument_playlist_id "$2" ; shift ; shift  ;;
79
+	    --)  shift; break ;;
80
+	    * ) print_invalid_option $1 ; exit 1 ;;
81
+	esac
82
+    done
83
+    return
84
+}
85
+
86
+handle_arguments "$@"