updated slightly
This commit is contained in:
parent
f9cf2b40e1
commit
424b709845
1 changed files with 26 additions and 33 deletions
53
pomodoro
53
pomodoro
|
@ -17,36 +17,39 @@ POMODORO_TODO_FILE="$POMODORO_LOG_DIRECTORY/TODO.txt"
|
||||||
# times are in minutes
|
# times are in minutes
|
||||||
POMODORO_WORKING_TIME=25
|
POMODORO_WORKING_TIME=25
|
||||||
POMODORO_SHORT_RELAX_TIME=5
|
POMODORO_SHORT_RELAX_TIME=5
|
||||||
POMODORO_LONG_RELAX_TIME=30
|
POMODORO_LONG_RELAX_TIME=15
|
||||||
# you can install get-shit-done at
|
# you can install get-shit-done at
|
||||||
# http://github.com/yogsototh/get-shit-done.git
|
# http://github.com/yogsototh/get-shit-done.git
|
||||||
# If you want to block some popular website
|
# If you want to block some popular website
|
||||||
# during your work session.
|
# during your work session.
|
||||||
# not you can overide these functions in $HOME/.pomodoro
|
# note you can overide these functions in $HOME/.pomodoro
|
||||||
|
|
||||||
function focus_on() {
|
has(){
|
||||||
[[ -x =get-shit-done ]] && {
|
which $1 >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
focus_on() {
|
||||||
|
has get-shit-done && {
|
||||||
sudo =get-shit-done work
|
sudo =get-shit-done work
|
||||||
print -- "[focus on]"
|
print -- "[focus on]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function focus_off() {
|
focus_off() {
|
||||||
[[ -x =get-shit-done ]] && {
|
has get-shit-done && {
|
||||||
sudo =get-shit-done play
|
sudo =get-shit-done play
|
||||||
print -- "[focus off]"
|
print -- "[focus off]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pomodoro_work_started() { focus_on }
|
pomodoro_work_started() { focus_on }
|
||||||
function pomodoro_work_time_ended() {}
|
pomodoro_work_time_ended() {}
|
||||||
function pomodoro_pause_started() { focus_off }
|
pomodoro_pause_started() { focus_off }
|
||||||
function pomodoro_pause_time_ended() { focus_on }
|
pomodoro_pause_time_ended() { focus_on }
|
||||||
|
|
||||||
# used to list latests task names
|
# used to list latests task names
|
||||||
typeset -U latestTasks
|
typeset -U latestTasks
|
||||||
typeset -U todoTasks
|
typeset -U todoTasks
|
||||||
|
|
||||||
function showConfMessage() {
|
showConfMessage() {
|
||||||
print -- "You can use the \$HOME/.pomodoro file to declare your own notification system"
|
print -- "You can use the \$HOME/.pomodoro file to declare your own notification system"
|
||||||
print -- "For example you could add: "
|
print -- "For example you could add: "
|
||||||
print -- "POMODORO_NOTIFY=\"notify_cmd --message=%m\""
|
print -- "POMODORO_NOTIFY=\"notify_cmd --message=%m\""
|
||||||
|
@ -55,7 +58,7 @@ function showConfMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# A nofity function as portable as possible
|
# A nofity function as portable as possible
|
||||||
function notify() {
|
notify() {
|
||||||
local message="$*"
|
local message="$*"
|
||||||
|
|
||||||
print -n -- "$message"
|
print -n -- "$message"
|
||||||
|
@ -63,39 +66,29 @@ function notify() {
|
||||||
eval $( echo $POMODORO_NOTIFY | sed 's/%m/"'$message'"/g' )
|
eval $( echo $POMODORO_NOTIFY | sed 's/%m/"'$message'"/g' )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $(uname) in
|
case $(uname) in
|
||||||
Darwin) # On Mac
|
Darwin) # On Mac
|
||||||
if [[ ! -x =growlnotify ]]; then
|
if has terminal-notifier; then
|
||||||
{
|
# you could install terminal-notifier from brew
|
||||||
print -- "Growl seems not to be installed"
|
terminal-notifier -message "$message" -title "pomodoro"
|
||||||
print -- "If you want to be notified you should install it"
|
|
||||||
print -- "More precisely I need the executable growlnotify"
|
|
||||||
showConfMessage
|
|
||||||
return
|
|
||||||
} >&2
|
|
||||||
fi
|
fi
|
||||||
|
if has growlnotify; then
|
||||||
growlnotify -m "[Pomodoro] $message"
|
growlnotify -m "[Pomodoro] $message"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
Linux) # on Ubuntu => sudo apt-get install libnotify-bin
|
Linux) # on Ubuntu => sudo apt-get install libnotify-bin
|
||||||
# on other systems libnotify
|
# on other systems libnotify
|
||||||
local DELAY=5 # in seconds
|
local DELAY=5 # in seconds
|
||||||
local ICON=/usr/share/icons/Tango/32x32/actions/appointment.png
|
local ICON=/usr/share/icons/Tango/32x32/actions/appointment.png
|
||||||
if [[ ! -x =notify-send ]]; then
|
if has notify-send; then
|
||||||
{
|
|
||||||
print -- "notify-send seems not installed"
|
|
||||||
print -- "Please install libnotify (apt-get install libnotify) on ubuntu for example"
|
|
||||||
showConfMessage
|
|
||||||
} >&2
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
notify-send \
|
notify-send \
|
||||||
--urgency=critical \
|
--urgency=critical \
|
||||||
--expire-time=$(( DELAY * 1000 )) \
|
--expire-time=$(( DELAY * 1000 )) \
|
||||||
--icon=$ICON "[Pomodoro] " $message
|
--icon=$ICON "[Pomodoro] " $message
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*) {
|
*) {
|
||||||
print -- "I don't made a notification system for your system"
|
print -- "I didn't made any notification for your system"
|
||||||
showConfMessage
|
showConfMessage
|
||||||
} >&2
|
} >&2
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue