Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

converted safe_say

  • Loading branch information...
commit bb2f8c4cc4b47a0a5343f7831a521cc22687a2d1 1 parent 5389cd2
Matthew Taylor authored September 19, 2012

Showing 1 changed file with 136 additions and 0 deletions. Show diff stats Hide diff stats

  1. 136  pom.ps1
136  pom.ps1
... ...
@@ -0,0 +1,136 @@
  1
+param(
  2
+	$message = $(throw("message required"))
  3
+)
  4
+
  5
+#
  6
+# NAME
  7
+#     pom -- a minimalist pomodoro-style time-tracker.
  8
+#
  9
+# SYNOPSIS
  10
+#     pom message [-l [logfile]]
  11
+#
  12
+# DESCRIPTION
  13
+#     The pom utility counts down for 20 minutes as you work on a task. It will
  14
+#     give an audible alert at 5 and 0 minutes if `say` is in the path and
  15
+#     executable.
  16
+#
  17
+#     -l [logfile]
  18
+#         If provided, log the completed task and timestamp to [logfile]. The
  19
+#         default is the POMLOG environment variable, if set. Otherwise, the
  20
+#         default is $HOME/pom.log.
  21
+#
  22
+# by @tobym (Toby Matejovsky) 2012-09-19.
  23
+# ported to powershell by @luv2code (Matthew Taylor) 2012-09-19
  24
+
  25
+# Runtime of a single session.
  26
+$time_in_minutes=25
  27
+
  28
+
  29
+# Print current status.
  30
+# First argument is number of minutes elapsed.
  31
+function print_status ($minutes) {
  32
+  clear
  33
+  $minutes_remaining=$(($time_in_minutes - $minutes))
  34
+  # $log_line=$(test -n "$logfile" && echo -n " ($logfile)" || echo -n "")
  35
+  # echo "Pomodoro$log_line: $minutes_remaining minutes remaining to complete: $goal"
  36
+  echo "Pomodoro: $minutes_remaining minutes remaining to complete: $goal"
  37
+  if ( $minutes_remaining -eq 5 ) {
  38
+      safe_say "$minutes_remaining minutes remaining in your pomadoro"
  39
+  }
  40
+}
  41
+
  42
+# Print final status. Optionally log this event.
  43
+function finish {
  44
+  clear
  45
+  $msg="$time_in_minutes minute pomodoro done at $(date) for: $goal"
  46
+  echo $msg
  47
+
  48
+  # if [ ! -z $logfile ]
  49
+  # then
  50
+    # echo $msg >> $logfile
  51
+  # fi
  52
+
  53
+  $break_msg="Pomadoro complete. Take a 5 minute break."
  54
+  echo $break_msg
  55
+  safe_say "$break_msg" # || ring_bell
  56
+}
  57
+
  58
+# Audibly say something, if possible.
  59
+function safe_say($text) {
  60
+	Add-Type -AssemblyName System.Speech
  61
+	$synthesizer = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
  62
+
  63
+	# This line converts the text to speech
  64
+	$synthesizer.Speak($text)
  65
+
  66
+}
  67
+finish
  68
+# # Try to ring the terminal bell.
  69
+# function ring_bell {
  70
+  # which -s tput && tput bel
  71
+# }
  72
+
  73
+# # Print short version of help.
  74
+# function print_usage {
  75
+  # echo "Usage: $0 message [-l [logfile]]"
  76
+# }
  77
+
  78
+# # Print help.
  79
+# function print_help {
  80
+  # help_text='
  81
+  # NAME
  82
+      # pom -- a minimalist pomodoro-style time-tracker.
  83
+
  84
+  # SYNOPSIS
  85
+      # pom message [-l [logfile]]
  86
+
  87
+  # DESCRIPTION
  88
+      # The pom utility counts down for 20 minutes as you work on a task. It will
  89
+      # give an audible alert at 5 and 0 minutes if `say` is in the path and
  90
+      # executable.
  91
+
  92
+      # -l [logfile]
  93
+          # If provided, log the completed task and timestamp to [logfile]. The
  94
+          # default is the POMLOG environment variable, if set. Otherwise, the
  95
+          # default is $HOME/pom.log.
  96
+# '
  97
+
  98
+  # echo "$help_text"
  99
+# }
  100
+
  101
+# # Main function.
  102
+# function run_main {
  103
+  # for minute in `seq $time_in_minutes`
  104
+  # do
  105
+    # print_status $(($minute-1))
  106
+    # sleep 60
  107
+  # done
  108
+  # finish
  109
+# }
  110
+
  111
+# # Parse options, and run main.
  112
+# goal=$1
  113
+# should_log=$2
  114
+# logfile=$3
  115
+# if [ "$should_log" = "-l" ] && [ -z "$logfile" ]
  116
+# then
  117
+  # if [ -z $POMLOG ]
  118
+  # then
  119
+    # logfile=$HOME/pom.log
  120
+  # else
  121
+    # logfile=$POMLOG
  122
+  # fi
  123
+# fi
  124
+
  125
+# if [ "$1" = "-h" ] || [ "$1" = "--help" ]
  126
+# then
  127
+  # print_help && exit 0
  128
+# elif [ -z "$1" ]
  129
+# then
  130
+  # print_usage && exit 1
  131
+# elif [ ! -z "$2" ] && [ "$2" != "-l" ]
  132
+# then
  133
+  # print_usage && exit 1
  134
+# else
  135
+  # run_main
  136
+# fi

0 notes on commit bb2f8c4

Please sign in to comment.
Something went wrong with that request. Please try again.