Add possibility to stop current active task
This commit is contained in:
parent
56628a8d0f
commit
bfcf7fb83d
23
rofi-task.sh
23
rofi-task.sh
|
@ -3,9 +3,14 @@
|
|||
# From Kehet
|
||||
## https://gist.github.com/Kehet/5ba8a530e52ea3a0ae251d756faef680
|
||||
|
||||
# Rofi colors
|
||||
# Vars {{{
|
||||
## Current tasks temp file
|
||||
readonly TASKW_CURRENT_LIST="/tmp/rofi-task.sh-current.tasks"
|
||||
|
||||
## Rofi colors
|
||||
black="#000000"
|
||||
blue="#0094cc"
|
||||
# }}}
|
||||
|
||||
is_task_running() { # {{{
|
||||
|
||||
|
@ -20,11 +25,23 @@ is_task_running() { # {{{
|
|||
# }}}
|
||||
display_current_task() { # {{{
|
||||
|
||||
## List active task(s) in a temp file
|
||||
touch -- "${TASKW_CURRENT_LIST}"
|
||||
printf '%b\n\n' " Choose a task to STOP" >> "${TASKW_CURRENT_LIST}"
|
||||
task +ACTIVE export | jq -r 'sort_by( -.urgency )[] | [ (.id|tostring), .description ] | join(" ")' >> "${TASKW_CURRENT_LIST}"
|
||||
|
||||
## Display active tasks list and get title from the choosen one
|
||||
TITLE=$(task +ACTIVE export | jq -r 'sort_by( -.urgency )[] | [ (.id|tostring), .description ] | join(" ")' |
|
||||
rofi -location 2 -lines 3 -no-auto-select -i -dmenu -p "RUNNING task(s)" -color-enabled -color-normal "${blue},${black},${blue},${black},${blue}" -color-window "${blue},${blue}" |
|
||||
TITLE=$(rofi -location 2 -lines 5 -no-auto-select -i -dmenu -p "RUNNING task(s)" -color-enabled -color-normal "${blue},${black},${blue},${black},${blue}" -color-window "${blue},${blue}" < "${TASKW_CURRENT_LIST}" |
|
||||
cut --delimiter=" " --field=2)
|
||||
|
||||
## Remove temp file
|
||||
rm --force -- "${TASKW_CURRENT_LIST}"
|
||||
|
||||
## If no task was selected (empty var) then exit
|
||||
[ -z "${TITLE}" ] && echo "Cancelled." && exit 0
|
||||
|
||||
## Stop the selected task and exit
|
||||
task "${TITLE}" stop >/dev/null && exit 0
|
||||
}
|
||||
# }}}
|
||||
select_task() { # {{{
|
||||
|
|
Loading…
Reference in New Issue