Home

Awesome

Tomato

Tomato is a command for running pomodoro in background. It's designed mainly to stay in MacBook touchbar.

For example, my touchbar looks like this:

1. Start

Start

2. Working (running)

Working

3. Short Break (running)

Short Break

Modes:

Quick Start

  1. Download the prebuilt command or build from source.

    You may need to run chmod +x tomato and put it in your $PATH.

  2. Config BetterTouchTool as this screenshot (port=12345). Don't forget to click Apply Changes.

  3. Config touchbar buttons with these Apple scripts:

    • Polling: Display information on the first button.
    • Start/Pause: Run when the first button is tapped.
    • Stop/Switch Mode: Run when the second button is tapped.

    Or copy config for the widget and the button then press Command+V inside BetterTouchTool.

  4. Copy UUID of the widget

  5. Start the tomato server. It will listen on :12321 by default.

    tomato -uuid=[UUID] -port=12345
    

    If you have trouble running the command, see this issue.

Usage

Tomato on TouchBar v1.2.0 (works with BetterTouchTool)

Default:
   tomato

With options:
   tomato -n=3 -colon=: -work=25m -short=300s -long=15m -listen=:12321

Send updates to BetterTouchTool:
   tomato -uuid=UUID -port=12345
   tomato -icon1=PATH_ICON1 -icon2=PATH_ICON2 -uuid=UUID -url=http://127.0.0.1:12345/update_touch_bar_widget/

Execute a command at the end of timer:
   tomato -command="terminal-notifier -title Pomodoro -message \"Hey, time is over\!\" -sound default"

Options:
  -async
    	Execute the command without waiting it to finish (use together with -command)
  -colon string
    	Custom separator (default ":")
  -colon-alt string
    	Alternative separator for break modes (default ":")
  -command string
    	Execute command at the end of timer
  -icon1 string
    	Icon for work (default red)
  -icon2 string
    	Icon for break session (default green)
  -listen string
    	Address to listen on (default ":12321")
  -long string
    	Long break interval (default "15m")
  -n int
    	Number of intervals between long break (default 4)
  -port string
    	BetterTouchTool port
  -short string
    	Short break interval (default "5m")
  -tick int
    	Duration in ms for sending updates (default 100) (default 100)
  -url string
    	URL to post update
  -uuid string
    	UUID of the widget
  -work string
    	Work interval (default "25m")

Build from source

  1. Install Go
  2. go build *.go

API

APISample OutputDescription
GET /status[R] 17:43 1/3 workCurrent status
GET /time17:43Current timer
POST /action/start17:43Start/pause the current interval.
POST /action/stop25:00Stop the current interval or switch mode.

Output

  1. State: [S] - stopped, [R] - running, [P] - paused.
  2. Timer: mm:ss - work interval, mmːss - break interval.
  3. Number of completed pomodoro in a set.
  4. Mode: work, short-break, long-break.

JSON

curl -H "Accept: application/json" http://localhost:12321/status
{"i":0,"mode":"work","n":4,"state":"[S]","timer":"25:00"}

AppleScript

1. Polling

try
    set reqURL to "http://localhost:12321/time"
    do shell script "curl " & quoted form of reqURL
on error
    return "00:00"
end try

2. Start / Pause

try
    set reqURL to "http://localhost:12321/action/start"
    do shell script "curl -X POST " & quoted form of reqURL
end try

3. Stop / Switch Mode

try
    set reqURL to "http://localhost:12321/action/stop"
    do shell script "curl -X POST " & quoted form of reqURL
end try

Notes

License