extracted planktimer and built out osxtimer
This commit is contained in:
parent
6d26e4d26b
commit
9e49551ef4
@ -1,32 +1,24 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
function planktimer() {
|
|
||||||
# dependencies: 'say' 'termdown' '.wryn/bash/rentdynamics'
|
function voicesed() { sed 's/\([^ ]*\) .*/\1/;'; }
|
||||||
message='Plank Time'
|
function voicelist() { say -v ? | voicesed; }
|
||||||
while true;
|
function voicelistenglish() { say -v ? | grep 'en_' | voicesed; }
|
||||||
do
|
function voicerandom() { voicelistenglish | shuf -n 1; }
|
||||||
termdown 1h30m;
|
|
||||||
clear;
|
function voicelistnormal() {
|
||||||
figlet "$message" | lolcat;
|
voicelistenglish |
|
||||||
# update slack status
|
sed '/Trinoids/d;/Zarvox/d;/Deranged/d;/Hysterical/d;/Bahh/d;/Bubbles/d'
|
||||||
rdplank;
|
|
||||||
say -v $(say -v ? | sed -n "/en_/p" | sed "s/ .*//" | shuf -n 1) "$message";
|
|
||||||
read -n 1;
|
|
||||||
if [ $1 ]; then
|
|
||||||
termdown $1;
|
|
||||||
say -v $(say -v ? | sed -n "/en_/p" | sed "s/ .*//" | shuf -n 1) "done";
|
|
||||||
fi
|
|
||||||
rdstart;
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
function voicerandomnormal() { voicelistnormal | shuf -n 1; }
|
||||||
|
|
||||||
function sayvoices() {
|
function sayvoices() {
|
||||||
for voice in $(say -v ? | sed 's/ .*//' | sed 's/ News//');
|
for voice in $(voicelist); do
|
||||||
do
|
|
||||||
say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //');
|
say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //');
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function sayone() {
|
function sayone() {
|
||||||
voice=$(say -v ? | sed 's/ .*//' | sed 's/ News//' | shuf -n 1);
|
local voice=$(voicerandom);
|
||||||
say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //');
|
say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
96
bash/osx/osxtimer
Normal file
96
bash/osx/osxtimer
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
function osxtimer() {
|
||||||
|
# dependency check
|
||||||
|
#termdown --version >/dev/null 2>&1 || { echo osxtimer requires 'termdown'; exit 1; }
|
||||||
|
#lolcat --version >/dev/null 2>&1 || lolcatError='`lolcat` is not installed';
|
||||||
|
#figlet --version >/dev/null 2>&1 || figletError='`figlet` is not installed';
|
||||||
|
|
||||||
|
# set defaults
|
||||||
|
local msg;
|
||||||
|
local timestring='10s';
|
||||||
|
local voice;
|
||||||
|
local critical;
|
||||||
|
local dontsaycountdown;
|
||||||
|
local dontsaymessage;
|
||||||
|
local dowait;
|
||||||
|
local dontdisplaymessage;
|
||||||
|
local displayHelp;
|
||||||
|
|
||||||
|
unset OPTIND;
|
||||||
|
while getopts "MVTYhwm:t:c:v:" opt; do
|
||||||
|
case $opt in
|
||||||
|
m) msg=$OPTARG ;; # optional message
|
||||||
|
M) dontdisplaymessage=t ;; # don't display message (but maybe say it)
|
||||||
|
t) timestring=$OPTARG ;; # termdown countdown string
|
||||||
|
c) critical=$OPTARG ;; # optional critical seconds remaining
|
||||||
|
v) voice=$OPTARG ;; # optional voice for critical seconds remaining
|
||||||
|
V) voice=$(voicerandom) ;; # select random voice
|
||||||
|
T) dontsaycountdown=t; ;; # don't readout countdown
|
||||||
|
V) dontsaymessage=t; ;; # don't readout message after countdown
|
||||||
|
w) dowait=t; ;; # don't wait for user input after the timer
|
||||||
|
h) displayHelp=t; ;; # display help message
|
||||||
|
:) echo option -$OPTARG requires an argument; displayHelp=t;
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
unset OPTIND;
|
||||||
|
|
||||||
|
# exit on fail
|
||||||
|
if [ $displayHelp ]; then
|
||||||
|
printf "
|
||||||
|
Correct usage:
|
||||||
|
[-t]\t countdown amount as a timestring used in 'termdown'
|
||||||
|
[-m]\t display message after countdown is finished
|
||||||
|
[-c]\t critical seconds param for 'termdown'
|
||||||
|
[-v]\t 'say' voice used for reading the message and countdown
|
||||||
|
[-V]\t select random voice for message and timer readout
|
||||||
|
[-T]\t used with -v or -V :: don't readout the countdown
|
||||||
|
[-Y]\t used with -v or -V :: don't readout the message
|
||||||
|
[-w]\t wait for user input after the timer
|
||||||
|
\n";
|
||||||
|
return 1;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# verify that the voice exists
|
||||||
|
say -v ? | grep $voice >/dev/null 2>&1 || unset voice;
|
||||||
|
|
||||||
|
local termdownargs="$timestring ";
|
||||||
|
[[ $critical ]] && termdownargs="$termdownargs -c $critical";
|
||||||
|
[[ $voice ]] && [ -z $dontsaycountdown ] && termdownargs="$termdownargs -v $voice";
|
||||||
|
termdown $termdownargs;
|
||||||
|
|
||||||
|
[[ $msg ]] && [ -z $dontdisplaymessage ] && figlet "$msg" | lolcat;
|
||||||
|
[[ $voice ]] && [ -z $dontsaymessage ] && say -v "$voice" "$msg";
|
||||||
|
|
||||||
|
[[ $dowait ]] && read -n 1; # wait for user input
|
||||||
|
}
|
||||||
|
|
||||||
|
function rdexercise() {
|
||||||
|
local message='Plank time!';
|
||||||
|
local delay='1h30m';
|
||||||
|
local count;
|
||||||
|
|
||||||
|
# flagged arguments
|
||||||
|
unset OPTIND;
|
||||||
|
while getopts "m:t:c:" opt; do
|
||||||
|
case $opt in
|
||||||
|
m) message=$OPTARG ;; # optional message
|
||||||
|
t) timeout=$OPTARG ;; # termdown countdown string
|
||||||
|
c) count=$OPTARG ;; # length of exercise as a timestring
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
unset OPTIND;
|
||||||
|
|
||||||
|
# operation loop
|
||||||
|
while true; do
|
||||||
|
rdstart >/dev/null 2>&1;
|
||||||
|
clear; osxtimer -VT -m "$message" -t "$delay";
|
||||||
|
rdplank >/dev/null 2>&1;
|
||||||
|
|
||||||
|
read -n 1; clear;
|
||||||
|
[[ $count ]] && osxtimer -c 10 -m "Done" -v "$(voicerandomnormal)" -t "$count";
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
alias planktimer='rdexercise -c';
|
||||||
|
alias pushuptimer='rdexercise -m "Push-up time!" -t "1h" -c';
|
Loading…
Reference in New Issue
Block a user