-
-
Save jacaetevha/6bf3f03fbc8df8cd37b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
input=$(echo $input | tr '\r' '\n') | |
# 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