Skip to content

Instantly share code, notes, and snippets.

@obstschale
Created January 20, 2022 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obstschale/37114fc9ec48498619d4724435f33424 to your computer and use it in GitHub Desktop.
Save obstschale/37114fc9ec48498619d4724435f33424 to your computer and use it in GitHub Desktop.
xbar script for watson
#!/bin/bash
# Watson Status
#
# by Antoine Corcy <contact@sbin.dk>
#
# <xbar.title>Watson Status</xbar.title>
# <xbar.version>1.0</xbar.version>
# <xbar.author>Antoine Corcy</xbar.author>
# <xbar.author.github>toin0u</xbar.author.github>
# <xbar.desc>Shows Watson's status</xbar.desc>
# <xbar.dependencies>Watson</xbar.dependencies>
# <xbar.image>https://i.imgur.com/3OuXrWn.png</xbar.image>
#
# Dependencies:
# watson (http://tailordev.github.io/Watson/)
# get the status text
status=$(/opt/homebrew/bin/watson status)
# total time today
total=$(/opt/homebrew/bin/watson report --from=$(date +%Y-%m-%d) --to=$(date +%Y-%m-%d) --no-pager --current | grep 'Total')
# show watson
if [[ "$status" == "No project started." ]]
then
echo "⏱ ${total:7}"
exit
fi
# get the project name
project=$(/opt/homebrew/bin/watson status --project)
# get the started time and uppercase the sentence
started=$(echo "$status" | grep -E -o 'started (.*) \(')
started="$(tr '[:lower:]' '[:upper:]' <<< "${started:0:1}")${started:1}"
# get the tags
tags=$(echo "$status" | awk '{printf "Tags: %s\n", $3}')
# main
echo "$project (${total:7})"
echo "---"
echo "${started/(/}"
echo "$total"
echo "$tags"
echo "---"
echo "Timer stoppen | terminal=false refresh=true shell=/opt/homebrew/bin/watson param1=stop | key=CmdOrCtrl+k"
echo "Start: 'Customer Success'| terminal=false refresh=true shell=/opt/homebrew/bin/watson param1=start param2=CS"
echo "---"
echo "Edit Plugins| terminal=false refresh=true shell=/opt/homebrew/bin/code param1=\"/Users/username/Library/Application Support/xbar/plugins\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment