Files
dotfiles/swiftbar/org-clock.1m.sh
Matt Anderson 71fe62d71c many updates
2026-05-29 17:50:15 -05:00

30 lines
678 B
Bash
Executable File

#!/bin/bash
# <xbar.title>Org Clock</xbar.title>
# <xbar.desc>Shows currently clocked org task (fixed open-clock detection)</xbar.desc>
# ←←← CHANGE THIS TO YOUR ACTUAL ORG FOLDER
ORG_DIR="$HOME/doc/org" # e.g. ~/Documents/org or ~/Dropbox/org
if [[ ! -d "$ORG_DIR" ]]; then
echo "⏱ Org folder not found"
exit 0
fi
TASK=$(find "$ORG_DIR" -name "*.org" -type f -print0 2>/dev/null \
| xargs -0 awk '
/^\*+ / { headline = $0 }
/CLOCK: \[/ && !/--/ {
print headline
exit
}
' \
| head -n 1 \
| sed -E 's/^[ \t]*\*+[ \t]*//')
if [[ -n "$TASK" ]]; then
echo "$TASK"
else
echo "⏱ No clock"
fi