aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgromo35
1 files changed, 25 insertions, 10 deletions
diff --git a/gromo b/gromo
index eb133da..7e3474a 100755
--- a/gromo
+++ b/gromo
@@ -27,16 +27,22 @@ TODAY_DIR=$DATA_DIR/$(date -I)
DING_FILE=$CACHE_DIR/ding.opus
STATE_FILE=${XDG_STATE_HOME:-$HOME/.local/state}/gromo
+FS=:
+
cmd_help() {
cmd=$(basename "$0")
echo -e "Usage:
- $cmd -h \tShow this help
- $cmd -s \tShow status
- $cmd -l \tList past gromos
- $cmd -x \tReturn state formatted for display in xmobar
+ $cmd -h \tShow this help
+ $cmd -s \tShow status
+ $cmd -l \tList past gromos
+ $cmd -x \tReturn state formatted for display in xmobar
+ $cmd [options] <task>\tStart task
+
+ Options:
- $cmd [task]\tStart task
+ -1
+ Oneshot: stop after first gromo is completed without blocking the screen.
Tasks can be divided in subtasks by using dots (.), e.g., 'gromo work.retro'. Only the first level
is taken into account for organization purposes: the top-level task is considered the 'main task'
@@ -82,7 +88,7 @@ cmd_status() {
sum_subtasks() {
file=$1
- awk -F: '{ sum += $2 } END { print sum }' "$file"
+ awk -F $FS '{ sum += $2 } END { print sum }' "$file"
}
inc_subtask() {
@@ -90,10 +96,10 @@ inc_subtask() {
maintask="${fulltask%%.*}"
task_file="$TODAY_DIR/$maintask"
if [ -f "$task_file" ]; then
- awk -F: "\$1 == \"$task\" { \$2 += 1; added=1 } { print } END { if (!added) { print \"$task\" FS 1 } }" "$task_file" > tmp
+ awk -F $FS "\$1 == \"$task\" { \$2 += 1; added=1 } { print \$1 FS \$2 } END { if (!added) { print \"$task\" FS 1 } }" "$task_file" > tmp
mv tmp "$task_file"
else
- echo "$task 1" > "$task_file"
+ echo "${task}${FS}1" > "$task_file"
fi
}
@@ -108,9 +114,13 @@ pp_seconds() {
fi
}
-optspec="hslx"
+optspec="1hslx"
while getopts "$optspec" optchar; do
case "$optchar" in
+ 1)
+ oneshot=1
+ shift;
+ ;;
h)
cmd_help
exit 0
@@ -134,7 +144,7 @@ while getopts "$optspec" optchar; do
esac
done
-if [ "$#" -ge 1 ]; then
+if [ "$#" -eq 1 ]; then
fulltask="$1"
else
cmd_help
@@ -161,6 +171,11 @@ while true; do
inc_subtask "$fulltask"
+ if [ "$oneshot" = "1" ]; then
+ mpv --no-terminal "$DING_FILE" &
+ exit 0
+ fi
+
(sleep $STOP_SECONDS && mpv --no-terminal "$DING_FILE") &
slock || exit
done