summaryrefslogtreecommitdiffstats
path: root/.local/bin/done
blob: 8bb0a3d00e0fe2aa356d10001ad66fa2dc32aff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

# we `start` tasks through taskwarrior which uses a hook to start them in
# timewarrior

function say_cancel { notify-send "cancelling, no action taken" "" --app-name="done" --icon="dialog-cancel"; }

if ACTIVE_TASK=$(task active); then

    task_id=$(echo "${ACTIVE_TASK}" | head -n4 | tail -n1 | cut -d' ' -f1)
    task_description=$(echo "${ACTIVE_TASK}" | head -n4 | tail -n1 | cut -d' ' -f2-)

    if choice=$(printf "done\npause" | rofi -dmenu -p "${task_description}" -lines 2 -no-custom); then

        if [[ ${choice} == "done" ]]; then
            task "done" "${task_id}"
            notify-send "👏👏👏 good work there" "task ${task_description} is complete" --app-name="done" --icon="checkmark"
        elif [[ ${choice} == "pause" ]]; then
            task "stop" "${task_id}"
            notify-send "🛑 let's put a pause on this" "stopping task ${task_description}" --app-name="done" --icon="dialog-apply"
        else
            echo "this is impossible..."
            exit 1
        fi

        if annot=$(printf "5 - perfect flow\n4 - progress, still\n3 - rather be somewhere else\n2 - ugh\n1 - not even" | rofi -dmenu -p "${task_description}" -lines 5 -no-custom); then
            timew "@1" annotate "${annot:0:1}"
        else
            if maybe_delete=$(printf "no no\nyea" | rofi -dmenu -p "should we delete the tracking?" -lines 2 -no-custom); then
                if [[ "${maybe_delete}" == "no no" ]]; then
                    notify-send "tracking unannotated, not deleted" "nobody will know how that went" --app-name="done" --icon="itmages-question"
                elif [[ "${maybe_delete}" == "yea" ]]; then
                    timew delete "@1"
                    notify-send "tracking deleted" "like you never worked on that" --app-name="done" --icon="pack-more"
                fi
            fi
        fi
    else
        say_cancel
    fi
else
    if wanna_start=$(printf '%s' "$(task custom_done | tail -n +4 | head -n -2)" | rofi -dmenu -p 'select a task' -i -no-custom); then
        task_id=$(echo "${wanna_start}" | xargs | cut -d' ' -f1)
        task_description=$(echo "${wanna_start}" | xargs | cut -d' ' -f2-)

        task "start" "${task_id}"
        notify-send "good luck then" "🤓 ${task_description} now" --app-name="done" --icon="go-next"
    else
        say_cancel
    fi
fi