dots


dots / scripts / Scripts
xxwhirlpool  ·  2026-04-21

ladyflash_ical

 1#!/usr/bin/env bash
 2
 3# don't take args
 4if [[ "$#" -gt 0 ]]; then
 5	echo "Usage: ical_add [FOLLOW PROMPTS]"
 6	exit 1
 7fi
 8
 9# basic functions
10die() {
11    echo "canceled" && exit 1
12}
13
14ginput() {
15	gum input --placeholder "$@"
16}
17
18# define calendar file
19calfile="/home/kat/Projects/mine/ladyflash/public/feeds/cal/Music_Releases.ics"
20
21# remove vcalend for now
22sed -i '/END:VCALENDAR/d' "$calfile"
23
24# read/take input and store in variables
25summary=$(ginput "Artist Type 'NAME'") || die
26dtstart=$(ginput "the release date, format: 20260417") || die
27dtend=$(date -d "$dtstart+1 day" +%Y%m%d) || die
28dtstamp=$(date -d "$dtstart" +'%Y%m%dT%H%M%SZ') || die
29uuid=$(uuidgen | tr "[:lower:]" "[:upper:]") || die
30categories=$(ginput "K-Pop,Pop") || die
31
32# idk if this does anything but
33# it's here just in case lol
34if [[ -z "$summary" || -z "$dtstart" || -z "$dtend" || -z "$dtstamp" || -z "$uuid" || -z "$categories" ]]; then
35    die
36fi
37
38# add everything to the calendar
39cat << EOF | perl -pe "chomp if eof" >> "$calfile"
40BEGIN:VEVENT
41SUMMARY:$summary
42DTSTART;VALUE=DATE:$dtstart
43DTEND;VALUE=DATE:$dtend
44DTSTAMP:$dtstamp
45UID:$uuid
46SEQUENCE:0
47CATEGORIES:$categories
48END:VEVENT
49EOF
50
51# add back in the vcalend
52echo -e "\nEND:VCALENDAR" >> "$calfile"