Add taskwarrior i3block
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a92b1bd7d8
commit
2bdc33dd2b
2 changed files with 38 additions and 0 deletions
30
.config/i3blocks/taskwarrior
Executable file
30
.config/i3blocks/taskwarrior
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
source "${HOME}/bin/script_framework.sh"
|
||||
|
||||
function colorized() {
|
||||
echo "<span color=\"$1\">$2</span>"
|
||||
}
|
||||
|
||||
count_pending=$(task status:pending count)
|
||||
count_due=$(task due.before=tomorrow and due.after=today and -status:completed count)
|
||||
count_overdue=$(task due.before=today and -status:completed count)
|
||||
count_active=$(task +ACTIVE count)
|
||||
|
||||
parts=("$(colorized "#8FAAFC" "${count_pending} pending")")
|
||||
|
||||
if [ $count_due -gt 0 ]; then
|
||||
parts+=("$(colorized "#FFD966" "${count_due} due")")
|
||||
fi
|
||||
|
||||
if [ $count_overdue -gt 0 ]; then
|
||||
parts+=("$(colorized "#dd0000" "${count_overdue} overdue")")
|
||||
fi
|
||||
|
||||
if [ $count_active -gt 0 ]; then
|
||||
active_tasks=$(task +ACTIVE export | jq -r '[ .[] | ["["+(.id|tostring)+"]", .description] | join(" ") ] | join(", ")')
|
||||
parts+=("$(colorized "#50fa7b" "Active: ${active_tasks}")")
|
||||
fi
|
||||
|
||||
echo "$(printf '\uf0ae') $(join_by ", " "${parts[@]}")"
|
|
@ -39,6 +39,14 @@ function info() {
|
|||
echo -e "${COLOR_CYAN}$@${COLOR_PLAIN}" >&2
|
||||
}
|
||||
|
||||
function join_by() {
|
||||
local d=$1
|
||||
shift
|
||||
echo -n "$1"
|
||||
shift
|
||||
printf "%s" "${@/#/$d}"
|
||||
}
|
||||
|
||||
function log_level_matches() {
|
||||
declare -A log_levels=(
|
||||
[debug]=0
|
||||
|
|
Loading…
Reference in a new issue