Skip to content

Instantly share code, notes, and snippets.

@ammojamo
Created December 6, 2011 23:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ammojamo/1440611 to your computer and use it in GitHub Desktop.
Save ammojamo/1440611 to your computer and use it in GitHub Desktop.
Time tracking bash script for Mac OS X - periodically asks what you have been doing
#!/bin/sh
input=
while true
do
input="$(/usr/bin/osascript 2>/dev/null <<-__HEREDOC__
with timeout of 300 seconds
tell application "System Events"
activate
set notes to display dialog "What ya been up to?" \
with title "Oi!" \
with icon note \
default answer "$input" & return & return & return & return \
buttons {"Cancel", "OK"} \
default button 2 \
giving up after 295
set the_result to the result
set gave_up to gave up of the_result
if gave_up is true then
return "Away"
end if
keystroke "h" using command down
return text returned of notes as string
end tell
end timeout
__HEREDOC__
)"
# replace CR with LF
' 'ut=$(echo $input | tr '
')
# trim whitespace
input=$(expr "$input" : '[[:space:]]*\(.*[^[:space:]]\)[[:space:]]*$')
echo "$(date "+%Y-%m-%d,%H:%M:%S"),\"$input\"" >> time-log-$(date "+%Y-%m-%d").txt
sleep 1800
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment