Skip to content

Instantly share code, notes, and snippets.

@phuntik
Created June 28, 2023 10:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phuntik/90ea6bb03c955cdc1ba3e0cc465b234d to your computer and use it in GitHub Desktop.
Save phuntik/90ea6bb03c955cdc1ba3e0cc465b234d to your computer and use it in GitHub Desktop.
i3blocks notify-send calendar
#! /bin/bash
send_current() {
TODAY=$(date '+%-d')
month=$(ncal -bhM)
BODY=$( tail -n7 <<< $month | sed -z "s/$TODAY/<span bgcolor='white' color='black'>$TODAY<\/span>/1" | sed "s/\(.*\)\(.\{7\}\)$/\1<span color='IndianRed'>\2<\/span>/")
HEAD=$(echo "$month" | head -n1)
notify-send -u critical \
"$HEAD" "$BODY"
}
send_next() {
MONTH_n=$(date -d "+1 month" '+%m %Y')
month=$(ncal -bhM $MONTH_n)
BODY=$( tail -n7 <<< $month | sed "s/\(.*\)\(.\{7\}\)$/\1<span color='IndianRed'>\2<\/span>/" )
HEAD=$( head -n1 <<< $month)
notify-send -u critical \
"$HEAD" "$BODY"
}
send_prev() {
MONTH_n=$(date -d "-1 month" '+%m %Y')
month=$(ncal -bhM $MONTH_n)
BODY=$( tail -n7 <<< $month | sed "s/\(.*\)\(.\{7\}\)$/\1<span color='IndianRed'>\2<\/span>/" )
HEAD=$( head -n1 <<< $month)
notify-send -u critical \
"$HEAD" "$BODY"
}
handle_action() {
send_next;
send_current;
send_prev;
}
handle_action
@phuntik
Copy link
Author

phuntik commented Jun 28, 2023

I use this script to spawn 3-month calendar with notify-send by clicking on datetime section with below i3blocks config:

[time]
markup=pango
command=date '+<b>%a %d/%m <big>%H:%M</big>:%S</b>'; if [ $BLOCK_BUTTON -eq 1 ]; then $HOME/.bin/i3/calendar; fi
interval=1

image

Critical level of notification is optional. I just use it for dunst to not to dismiss notifications by timer, so they go away only by clicking.
Also It has some bugs in visual on weekends AFAIK but i don't really struggle with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment