summaryrefslogtreecommitdiff
path: root/dotfiles/hyprland/.local/bin/waybar-date
blob: 72a0000376395be0e15cda8381dc78642ed52adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
# Waybar date module with two-month calendar tooltip
DATE=$(date '+%a, %b %d %Y')
TODAY=$(date '+%-d')
MONTH=$(date '+%B %Y')

# Generate current month (with today highlighted) stacked above next month
NEXT_M=$(date -d 'next month' '+%-m')
NEXT_Y=$(date -d 'next month' '+%Y')
CUR=$(cal | sed "s/\b${TODAY}\b/<span color='#daa520'><b><u>${TODAY}<\/u><\/b><\/span>/")
NEXT=$(cal "$NEXT_M" "$NEXT_Y")
HIGHLIGHTED=$(printf '%s\n%s' "$CUR" "$NEXT")

TOOLTIP="<tt>${HIGHLIGHTED}</tt>"

# Escape for JSON
TOOLTIP=$(echo "$TOOLTIP" | sed ':a;N;$!ba;s/\n/\\n/g')

printf '{"text": "%s", "tooltip": "%s"}\n' "$DATE" "$TOOLTIP"