Add taskwarrior i3block

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-11-21 15:47:45 +01:00
parent a92b1bd7d8
commit 2bdc33dd2b
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 38 additions and 0 deletions

30
.config/i3blocks/taskwarrior Executable file
View 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[@]}")"

View file

@ -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