35 lines
605 B
Bash
Executable File
35 lines
605 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
STATE_FILE="/tmp/pomodoro-preset"
|
|
POMODORO_BIN="$HOME/.local/bin/waybar-module-pomodoro"
|
|
|
|
if [[ ! -x "$POMODORO_BIN" ]]; then
|
|
echo "Error: $POMODORO_BIN is missing or not executable." >&2
|
|
exit 1
|
|
fi
|
|
|
|
current="A"
|
|
if [[ -f "$STATE_FILE" ]]; then
|
|
read -r current < "$STATE_FILE" || current="A"
|
|
fi
|
|
|
|
if [[ "$current" == "A" ]]; then
|
|
next="B"
|
|
work=50
|
|
short=10
|
|
long=20
|
|
else
|
|
next="A"
|
|
work=25
|
|
short=5
|
|
long=15
|
|
fi
|
|
|
|
"$POMODORO_BIN" set-work "$work"
|
|
"$POMODORO_BIN" set-short "$short"
|
|
"$POMODORO_BIN" set-long "$long"
|
|
|
|
printf '%s\n' "$next" > "$STATE_FILE"
|