From 9bba59cd6d6f59621f33e11bb975f203ceb34826 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Thu, 8 Aug 2024 12:20:54 +0200 Subject: done: tofi/rofi distinction --- .local/bin/done | 50 -------------------------------------- .local/bin/done##default | 50 ++++++++++++++++++++++++++++++++++++++ .local/bin/done##h.qualle | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 50 deletions(-) delete mode 100755 .local/bin/done create mode 100755 .local/bin/done##default create mode 100755 .local/bin/done##h.qualle (limited to '.local/bin') diff --git a/.local/bin/done b/.local/bin/done deleted file mode 100755 index 950541c..0000000 --- a/.local/bin/done +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env 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=$(task active_task_id | xargs | cut -d' ' -f3) - 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 diff --git a/.local/bin/done##default b/.local/bin/done##default new file mode 100755 index 0000000..950541c --- /dev/null +++ b/.local/bin/done##default @@ -0,0 +1,50 @@ +#!/usr/bin/env 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=$(task active_task_id | xargs | cut -d' ' -f3) + 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 diff --git a/.local/bin/done##h.qualle b/.local/bin/done##h.qualle new file mode 100755 index 0000000..d2580ca --- /dev/null +++ b/.local/bin/done##h.qualle @@ -0,0 +1,62 @@ +#!/usr/bin/env 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 + # We have a running task + task_id=$(task active_task_id | xargs | cut -d' ' -f3) + task_description=$(echo "${ACTIVE_TASK}" | head -n4 | tail -n1 | cut -d' ' -f2-) + + if choice=$(printf "done\npause" | tofi --prompt-text="${task_description}"); then + # complete or pause the task, closing tofi doesn't touch the task + if [[ -z $choice ]]; then + say_cancel + exit + fi + + 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" | tofi --prompt-text="${task_description}"); then + + if [[ -z $annot ]]; then + # exited out from annotation, is something wrong? + if maybe_delete=$(printf "no no\nyea" | tofi --prompt-text="should we delete the tracking?"); 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 + timew "@1" annotate "${annot:0:1}" + fi + fi +else + # No running task, maybe start one? + if wanna_start=$(printf '%s' "$(task custom_done | tail -n +4 | head -n -2)" | tofi --prompt-text="select a task: "); then + if [[ -z $wanna_start ]]; then # empty, above prompt exited + say_cancel + exit + fi + + # picked a task, start it + 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" "${task_description} now" --app-name="done" --icon="go-next" + fi +fi -- cgit v1.2.3-70-g09d2