aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgromo68
1 files changed, 39 insertions, 29 deletions
diff --git a/gromo b/gromo
index d4adff4..11eb604 100755
--- a/gromo
+++ b/gromo
@@ -27,35 +27,45 @@ TODAY_DIR=$DATA_DIR/$(date -I)
DING_FILE=$CACHE_DIR/ding.opus
STATE_FILE=${XDG_STATE_HOME:-$HOME/.local/state}/gromo
-if [ "$1" = "--xmobar-status" ]; then
- state=idle
- [ -f "$STATE_FILE" ] && state=$(cat $STATE_FILE)
-
- color=red
- [ "$state" = "idle" ] && color=green
-
- if [ -d "$TODAY_DIR" ]; then
- declare -a today
- for gromo in "$TODAY_DIR"/*; do
- today+=("$(basename $gromo): $(cat $gromo)")
- done
- [ -n "$today" ] && today=" (${today[@]})"
- fi
- echo "<fc=$color>$state</fc>$today"
- exit 0
-elif [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
- cmd=$(basename $0)
- echo -e "Usage:
- $cmd --xmobar-status \tReturn state formatted for display in xmobar
- $cmd --list | -l \tList past gromos
- $cmd --help | -h \tShow this help
- $cmd [gromo] [descr] \tStart counting gromo (default gromo: "work")
- "
- exit 0
-elif [ "$1" = "--list" ] || [ "$1" = "-l" ]; then
- find $DATA_DIR/ -type f -print | xargs -n 1 basename | sort -u
- exit 0
-elif [ "$#" -ge 1 ]; then
+optspec="hlx"
+while getopts "$optspec" optchar; do
+ case "$optchar" in
+ h)
+ cmd=$(basename $0)
+ echo -e "Usage:
+ $cmd -h\tShow this help
+ $cmd -l\tList past gromos
+ $cmd -x\tReturn state formatted for display in xmobar
+
+ $cmd [task] [subtask]\tStart task (default: "work")
+ "
+ exit 0
+ ;;
+ l)
+ find $DATA_DIR/ -type f -print | xargs -n 1 basename | sort -u
+ exit 0
+ ;;
+ x)
+ state=idle
+ [ -f "$STATE_FILE" ] && state=$(cat $STATE_FILE)
+
+ color=red
+ [ "$state" = "idle" ] && color=green
+
+ if [ -d "$TODAY_DIR" ]; then
+ declare -a today
+ for gromo in "$TODAY_DIR"/*; do
+ today+=("$(basename $gromo): $(cat $gromo)")
+ done
+ [ -n "$today" ] && today=" (${today[@]})"
+ fi
+ echo "<fc=$color>$state</fc>$today"
+ exit 0
+ ;;
+ esac
+done
+
+if [ "$#" -ge 1 ]; then
gromo="$1"
desc="$2"
else