Skip to content

Instantly share code, notes, and snippets.

@tuanchauict
Last active March 31, 2022 03:08
Show Gist options
  • Save tuanchauict/47c9cfb7e0a24971c2d931ce27fffe0c to your computer and use it in GitHub Desktop.
Save tuanchauict/47c9cfb7e0a24971c2d931ce27fffe0c to your computer and use it in GitHub Desktop.
Schedule today online meeting

Why

5-minute before an online meeting is the hard time because we need to separate our mind both for checking the clock and keeping working on what we are doing. This does not guaratee we won't miss 1, or 2, or sometimes 10 minutes.

This simple script is to help us early register online meeting, then it will open the link on time.

Usage

Let's assume that we set alias to the file as zoomin

alias zoomin="sh /path/to/zoomin.sh"

Parameters:

zoomin
zoomin : list all schedules
zoomin tick : if there is any meeting at current time, open the link
zoomin rm HH-MM : remove the meeting at HH:MM
zoomin HH-MM [URL] : Check the link for meeting at HH:MM or set a new schedule at HH:MM with URL
zoomin HH [URL] : Check the link for meeting at HH:00 or set a new schedule at HH:00 with URL
zoomin weekday-HH-MM [URL] : Set a new weekly schedule at HH:MM for weekly meeting on weekday with URL (weekday in mon|tue|wed|thu|fri|sat|sun)
zoomin month-day-HH-MM <URL> : Set a new schedule at month-day HH:MM for meeting on weekday with URL (month-date in format 01-12, 01-31)

(*) HH-MM : House-Minute (24h format)

Example:

zoomin 10-00 https://meeting.com/123456 # Schedule a meeting at 10:00 with https://meeting.com/123456
zoomin                                  # 10-00
zoomin 10-00                            # https://meeting.com/123456
zoomin rm 10-00                         # Remove meeting at 10:00
zoomin tue-10-10 https://meeting.com/12 # Schedule a weekly meeting at 10:00 every Tuesday with https://meeting.com/12

Cron job

*/5 * * * * sh /path/to/zoomin.sh tick

Check each 5 minutes (0, 5, 10, etc.) whether it's a scheduled meeting. If yes, open that meeting.

#!/bin/bash -e
# zoomin
# zoomin : list all schedules
# zoomin tick : if there is any meeting at current time, open the link
# zoomin rm HH-MM : remove the meeting at HH:MM
# zoomin HH-MM [URL] : Check the link for meeting at HH:MM or set a new schedule at HH:MM with URL
# zoomin HH [URL] : Check the link for meeting at HH:00 or set a new schedule at HH:00 with URL
# zoomin weekday-HH-MM [URL] : Set a new weekly schedule at HH:MM for weekly meeting on weekday with URL (weekday in mon|tue|wed|thu|fri|sat|sun)
# zoomin month-day-HH-MM <URL> : Set a new schedule at month-day HH:MM for meeting on weekday with URL (month-date in format 01-12, 01-31)
path="$HOME/.zoomin"
mkdir -p "$path"
function upper(){
echo $(python <<< "print '$1'.upper()")
}
function try_open_meeting_from_file() { # filepath [rm] : rm = remove
file="$1"
if [ -f "$file" ]; then
url=$(cat "$file")
open "$url"
if [[ "$2" == "rm" ]]; then
rm "$file"
fi
fi
}
function tick() {
currentTime=$(date +%H-%M)
monthDay="$(date +%m-%d)"
weekday=$(upper "$(date +%a)")
try_open_meeting_from_file "$path/$currentTime" rm # one time meeting within the day by time
try_open_meeting_from_file "$path/$monthDay-$currentTime" rm # one time meeting within the day by exact month-day
try_open_meeting_from_file "$path/$weekday-$currentTime" # weekly meeting
}
if [ -z "$1" ]; then
# List all schedules
ls "$path"
exit 0
fi
if [ "$1" == "tick" ]; then
tick
exit 0
fi
if [ "$1" == "rm" ]; then
target=$(upper "$2")
file="$path/$target"
if [ -f "$file" ]; then
rm "$file"
fi
exit 0
fi
time=$(upper "$1")
if [[ "$time" != *"-"* ]]; then
time="$time-00"
fi
if [ -z "$2" ]; then
cat "$path/$time"
exit 0
fi
echo "$2" >"$path/$time"
ls "$path"
@tuanchauict
Copy link
Author

The disadvantage of this script is we have to do the scheduling every day.

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