← Back

work timer tui

2026-01-20

I'm sick of using the timer on my phone, and I'm also kind of sick of convoluted macOS apps that run timers and create "work logs". I want something really simple... so maybe I'll try to make something myself, and learn a little bit of bash while I'm at it!

Here's what I have so far, it's pretty small and silly and I'm not even really sure it works...

#
# Input
#
# Format - "<time-minutes>:<task-text>"
# where i like to format <task-text> as "<project> - <specific thing>"
# Example - 5:work-timer-tui - prototyping a little work timer
INPUT_STRING="{query}"
#
# Constants
#
TARGET_FILE_PATH="/Users/zachshilton/Library/CloudStorage/Dropbox/Obsidian/zchsh/Thoughts/2026-01-20 - work log.md"
#
# Parse input argument
#
# Split input string on ":"
TIME_MINUTES=$(echo $INPUT_STRING | cut -d ':' -f 1)
TIME_SECONDS=$(echo "$TIME_MINUTES * 60" | bc)
# Split the task text
TASK_TEXT=$(echo $INPUT_STRING | cut -d ':' -f 2)
echo "Working on \"$TASK_TEXT\" for $TIME_MINUTES minutes..."
#
# Run the timer, then log to file
#
TASK_LINE="- $(date +"%Y-%m-%d") at $(date +"%H:%M") - logged $TIME_MINUTES minutes of work - $TASK_TEXT"
caffeinate -d -i -m -s -u -t $TIME_SECONDS \
    && echo "$TASK_LINE"  | sed 's/\\ / /g' >> $TARGET_FILE_PATH \
    && osascript -e "set volume output volume 70" \
    && afplay /Users/zachshilton/Library/CloudStorage/Dropbox/computer-stuff/alert-sounds/kettle-encoreinfinitum.m4r

Next steps

  • A "previous" or "continue" keyword would be nice...
    • Like work 10:previous or work 10:continue
    • Could maybe read in work log file to get previous entry? Seems like the simplest way to go about it
  • Auto-close the Terminal window when the timer ends
    • Ideally, do this only if writing to the log file was definitely successful
  • Implement some way to end the timer early
    • Aim would be to cancel the caffeinate command, but then proceed to the rest of the script, minus the afplay I guess? Maybe I could just prompt for input, and any input except the word exit or the letter q would just prompt for input again?
  • Write script to reformat work log to collapse adjacent timers
    • If adjacent lines only differ by minutes could, then combine those lines
    • Should be idempotent
    • This script could run at the end of every timer, if you want
  • echo a countdown clock as the timer elapses
    • Or maybe could look into a menu bar item or something? I do feel like that'd be kind of nice... Option to show the time left of course... but maybe better to just show the full time, and not have a countdown. Less stressful, I think. Maybe the name of the task being worked on.
  • Clear the output area before echo'ing the countdown clock, so it's nice & clean
  • Somehow get the countdown clock in the Terminal title bar
    • Currently says caffeinate or whatever