summary refs log tree commit diff
path: root/.config/waybar/module-calendar.sh
blob: 6b20e2f0eec11888e0522e79eaf0cfb49a8188f6 (plain) (blame)
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
#!/bin/bash
set -eu
[ -n "${DEBUG:-}" ] && set -x

shopt -s extglob

update() {
	local today tn
	local text

	# get events
	today=$(~/src/calsync/ics2calendartxt ~/calendars/**/**/* 2>/dev/null |
		grep -I "$(date -I)")
	[ -z "$today" ] && return

	tn=$(wc -l <<<"$today")

	# 	text="$today"
	# 	text="${text##"$(date +'%Y-%m-%d w%V %a ')"}"
	# 	text="${text##+([^ ]) }"

	text="󰃭 $tn"

	jq -nrc '{text:$text,tooltip:$tip}' \
		--arg tip "$today" \
		--arg text "$text"
}

update || echo '{}'