blob: 66be81b3c0c427cab93ed78a135f099f92cf4e8f (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/bin/sh
# Get the current time and the time in one hour
now=$(date +%s)
in_one_hour=$(date -d "+1 hour" +%s)
# Check for tasks due in the next hour
tasks_due_today=$(task due:tomorrow _ids)
tasks_due_count=0
tasks_due_list=""
for task_id in $tasks_due_today; do
task_due_date=$(task _get "$task_id".due)
task_due_epoch=$(date -d "$task_due_date" +%s)
task_description=$(task _get "$task_id".description)
# Check if the task is due within the next hour
if [ "$task_due_epoch" -gt "$now" ] && [ "$task_due_epoch" -le "$in_one_hour" ]; then
tasks_due_list="$tasks_due_list- $task_description\n"
tasks_due_count=$((tasks_due_count + 1))
fi
done
# Check for overdue tasks (tasks with due date in the past)
overdue_tasks=$(task +OVERDUE _ids)
overdue_count=0
overdue_list=""
for task_id in $overdue_tasks; do
task_description=$(task _get "$task_id".description)
overdue_list="$overdue_list- $task_description\n"
overdue_count=$((overdue_count + 1))
done
# Check for follow-up tasks
follow_up_tasks=$(task follow.is:Y _ids -PARENT)
follow_up_count=0
follow_up_list=""
for task_id in $follow_up_tasks; do
task_due_date=$(task _get "$task_id".due)
task_due_epoch=$(date -d "$task_due_date" +%s)
task_description=$(task _get "$task_id".description)
# Ensure that follow-up tasks are only shown if they are not overdue
if [ "$task_due_epoch" -ge "$now" ]; then
follow_up_list="$follow_up_list- $task_description\n"
follow_up_count=$((follow_up_count + 1))
fi
done
check_task_sync() {
if [ "$(task _get tw.syncneeded)" -eq 1 ]; then
tasks-sync
notify-send "📚 Tasks synced"
fi
}
# Handle mouse clicks
case $BLOCK_BUTTON in
1) # Combine actions for button 1 and button 2
notify-send "📚 Follow-up task(s) to complete:" "$(printf "%b" "$follow_up_list")
📕 Tasks due in the next hour:
$(printf "%b" "$tasks_due_list")
⏰ Overdue Tasks:
$(printf "%b" "$overdue_list")"
;;
2) check_task_sync ;;
3)
notify-send "🗂️ Task Module" "Shows task counts.
- Left click: Show tasks due soon.
- Middle click: Show follow-up tasks."
;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
# Output task information to dwmblocks
output=""
[ "$overdue_count" -gt 0 ] && output="${output}⏰$overdue_count "
[ "$follow_up_count" -gt 0 ] && output="${output}📚$follow_up_count "
[ "$tasks_due_count" -gt 0 ] && output="${output}📕$tasks_due_count " && notify-send -u critical "🚑 Tasks Remained!" "$tasks_due_list"
[ "$(task _get tw.syncneeded)" -eq 1 ] && output="${output}📑 "
echo "${output%* }"
|