You can see this as the Emacs-free version of Show Emacs org-timer countdown in macOS menubar.

I modified the original pomodoro timer script for xbar on macOS, made by Goran Gajic in the following ways:

  • Activate do-not-disturb mode during pomodori using the same shortcut as in Double Bonus macOS do-not-disturb during pomodoro. This is the most important change which helps my productivity tremendously.
  • At the end of the pomodoro, add a line describing the pomodoro to the end of today’s daily note
  • Play gong sound at the end of each pomodoro (use your own sound here, or comment out the afplay invocation)
  • After break, don’t automatically start next pomodoro - I might not be back yet - rather go into disabled / off mode.
#!/bin/bash
#
# <xbar.title>Pomodoro Timer</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Goran Gajic</xbar.author>
# <xbar.author.github>gorangajic</xbar.author.github>
# <xbar.desc>Pomodoro Timer that uses Pomodoro Technique™</xbar.desc>
# <xbar.image>http://i.imgur.com/T0zFY89.png</xbar.image>
 
# original source: https://github.com/matryer/xbar-plugins/blob/main/Time/pomodoro.1s.sh
# changes by cpbotha@vxlabs.com
# - activate DnD mode during pomodoro via shortcuts
# - log pomodoro to my daily note
# - play gong at end of pomodoro using afplay
# - go into disabled mode after break, not next pomodoro
 
# configure to your setup
DAILY_NOTE_DIR="$HOME/Google Drive/My Drive/notes/pkb4000/daily"
 
WORK_TIME=25
BREAK_TIME=5
 
TMP_DIR='/tmp'
 
#SAVE_LOCATION=$TMPDIR/bitbar-promodo
SAVE_LOCATION=$HOME/.bitbar-promodo
TOMATO='🍅'
 
WORK_TIME_IN_SECONDS=$((WORK_TIME * 60))
BREAK_TIME_IN_SECONDS=$((BREAK_TIME * 60))
 
CURRENT_TIME=$(date +%s)
 
if [ -f "$SAVE_LOCATION" ];
then
    DATA=$(cat "$SAVE_LOCATION")
 
else
    DATA="$CURRENT_TIME|0"
fi
 
TIME=$(echo "$DATA" | cut -d "|" -f1)
STATUS=$(echo "$DATA" | cut -d "|" -f2)
 
function changeStatus {
    echo "$CURRENT_TIME|$1" > "$SAVE_LOCATION";
    /usr/bin/osascript -e "display notification \"$2\" with title \"$TOMATO Pomodoro\" sound name \"$3\"" &> /dev/null
}
 
function _disableDND {
    /usr/bin/shortcuts run "Focus DND off"
}
 
function breakMode {
    _disableDND
    changeStatus "2" "Break Mode" "Glass"
}
 
function workMode {
    changeStatus "1" "Work Mode" "Blow"
    /usr/bin/shortcuts run "Focus DND on"
}
 
function disabledMode {
    _disableDND
    changeStatus "0" "Disabled" "Pebble"
}
 
case "$1" in
"work")
    workMode
    exit
  ;;
"break")
    breakMode
    exit
  ;;
"disable")
    disabledMode
    exit
  ;;
esac
 
 
 
function timeLeft {
    local FROM=$1
    local TIME_DIFF=$((CURRENT_TIME - TIME))
    local TIME_LEFT=$((FROM - TIME_DIFF))
    echo "$TIME_LEFT";
}
 
function getSeconds {
    echo $(($1 % 60))
}
 
function getMinutes {
    echo $(($1 / 60))
}
 
function printTime {
    SECONDS=$(getSeconds "$1")
    MINUTES=$(getMinutes "$1")
    printf "%s %02d:%02d| color=%s\n" "$TOMATO" "$MINUTES" "$SECONDS"  "$2"
}
 
case "$STATUS" in
# STOP MODE
"0")
    echo "$TOMATO"
  ;;
"1") # work
    TIME_LEFT=$(timeLeft $WORK_TIME_IN_SECONDS)
    if (( "$TIME_LEFT" < 0 )); then
        # append log of this completed pomodoro to the daily note
        DAILY_NOTE="$DAILY_NOTE_DIR/$(date +%Y)/$(date +%Y-%m-%d).md"
        # we're now at the end of the pomodoro; $TIME is when this pomodoro started in seconds
        printf "\n- 🍅 (begin:: %s) - (end:: %s): ADD_DESCRIPTION_HERE\n" "$(date -r $TIME +%Y-%m-%dT%H:%M)" "$(date +%Y-%m-%dT%H:%M)" >> "$DAILY_NOTE"
 
        # play that lovely gong sound
        afplay -v 0.5 $HOME/Music/meditation-gong.wav
        breakMode
    fi
    printTime "$TIME_LEFT" "red"
  ;;
"2") # break
    TIME_LEFT=$(timeLeft $BREAK_TIME_IN_SECONDS)
    if (("$TIME_LEFT" < 0)); then
        # cpbotha prefers MANUALLY and deliberately starting the next pom after break is over
        disabledMode
        #workMode
    fi
    printTime "$TIME_LEFT" "green"
  ;;
esac
 
echo "---";
echo "👔 Work | bash=\"$0\" param1=work terminal=false"
echo "☕ Break | bash=\"$0\" param1=break terminal=false"
echo "🔌 Disable | bash=\"$0\" param1=disable terminal=false"