From ad9e7cd5117c965222aae708f660e56d537914fc Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 6 Oct 2025 00:48:48 +0300 Subject: imported all of my Github gists from https://gist.github.com/rhaberkorn --- timebutler.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 timebutler.sh (limited to 'timebutler.sh') diff --git a/timebutler.sh b/timebutler.sh new file mode 100755 index 0000000..e45c461 --- /dev/null +++ b/timebutler.sh @@ -0,0 +1,27 @@ +#!env bash +# Minimalist Timebutler CLI interface +# ./timebutler start|pause|resume|stop|cancel|status [project] +# You have to set USERID and AUTH variables in ~/.timebutler! +# Run `curl -X POST 'https://timebutler.de/api/v1/users' -d "auth=$AUTH"` to fetch user ids. +set -e + +. ~/.timebutler +test -n "$AUTH" -a -n "$USERID" + +COMMAND=$1 +if [ -z "$COMMAND" ]; then + echo "Missing command" + exit 1 +fi + +PROJECT=$2 +if [ -n "$PROJECT" ]; then + PROJECTID=(`curl -s -X POST 'https://timebutler.de/api/v1/projects' -d "auth=$AUTH" | awk -F ';' "\\$2~/$PROJECT/ {print \\$1}"`) + if [ ${#PROJECTID[*]} != 1 ]; then + echo "Unknown or ambiguous project \"$PROJECT\"" + exit 1 + fi + ARGS="$ARGS -d projectid=$PROJECTID" +fi + +exec curl -X POST 'https://timebutler.de/api/v1/timeclock' -d "auth=$AUTH" -d "userid=$USERID" -d "command=$COMMAND" $ARGS -- cgit v1.2.3