Created
November 10, 2025 19:37
-
-
Save waynehoover/6d287fff306870392f07f7bf55113c06 to your computer and use it in GitHub Desktop.
Get next event from MeetingBar Shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Strip newlines and Unicode non-breaking spaces | |
| meeting_time=$(shortcuts run "Get Nearest Event Details" | tr -d '\n' | sed 's/[[:space:]]AM/ AM/g' | sed 's/[[:space:]]PM/ PM/g') | |
| if [ -z "$meeting_time" ]; then | |
| echo "No meetings" | |
| exit 0 | |
| fi | |
| # Parse the date (format: "MM/DD/YYYY, HH:MM AM/PM") | |
| # Use %l for hour (1-12 with possible leading space) | |
| meeting_timestamp=$(date -j -f "%m/%d/%Y, %l:%M %p" "$meeting_time" +%s 2>/dev/null) | |
| if [ -z "$meeting_timestamp" ]; then | |
| echo "No meetings" | |
| exit 0 | |
| fi | |
| # Calculate time difference | |
| current_time=$(date +%s) | |
| diff_seconds=$((meeting_timestamp - current_time)) | |
| diff_minutes=$((diff_seconds / 60)) | |
| # Format relative time | |
| if [ "$diff_minutes" -lt 1 ]; then | |
| echo "now" | |
| elif [ "$diff_minutes" -lt 60 ]; then | |
| echo "in ${diff_minutes}m" | |
| elif [ "$diff_seconds" -lt 86400 ]; then | |
| hours=$((diff_minutes / 60)) | |
| remaining_minutes=$((diff_minutes % 60)) | |
| if [ "$remaining_minutes" -eq 0 ]; then | |
| echo "in ${hours}h" | |
| else | |
| echo "in ${hours}h ${remaining_minutes}m" | |
| fi | |
| else | |
| days=$((diff_seconds / 86400)) | |
| echo "in ${days}d" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment