cleaned up the readme and made the program just a little easier to configure

This commit is contained in:
trav 2022-02-03 18:26:50 -05:00
parent 346db2ee55
commit 2edc99873a
2 changed files with 40 additions and 14 deletions

View File

@ -37,7 +37,7 @@ open hours at lab
```
## installation
## installation + configuration
1. clone or download the repo.
2. configure calendarender by opening calendarender.sh in your texteditor of choice and modify the line:
@ -46,24 +46,26 @@ open hours at lab
to say where your calendar file is. This must be the absolute path to your calendar file. If you don't have one just make an empty txt file there to start.
You might also like to configure recurring events. I have some SERIOUS ROOM FOR IMPROVEMENT here, it's true. Recurring events really ought to be in a separate config file. BUT ALAS, it works for me as recurring events rarely change, it is what it is, recurring events are hardcoded. So, if you have things that happen weekly or monthly and you want them to be auto-rendered, you'll need to modify this code block:
You might also like to configure recurring events. Recurring events really ought to be in a separate config file but currently they are hardcoded within the program itself. To add recurring events go down to where it says `############# render weekly things`. This section is broken down by day. There are a number of examples for Sundays that you can look at and modify for different days of the week/month. Anything in quotes after `echo` will be added to the calendar.
```
#every sunday
if [ "$dayOfWeek" = "Sun" ]; then echo "water plants">> $calendarFile; sunday=$(($sunday+1)); fi
```
_Make sure not to get rid of the section `sunday=$(($sunday+1))` because that is how the program keeps track of which sunday/monday/tuesday/(etc) we're on._
```
#second sunday
if [ "$dayOfWeek" = "Sun" ] && [ "$sunday" -eq 2 ]; then echo "example potluck">> $calendarFile; fi
#3rd sunday
if [ "$dayOfWeek" = "Sun" ] && [ "$sunday" -eq 3 ]; then echo "example potluck on third sunday">> $calendarFile; fi
#last sunday
if [ "$(date -v1d -v+"$tooFarNum"m -v-1d -v-sun +%a-%b-%d)" = "$(date -v1d -v+"$1"m -v+"$PLACEINMONTH"d +%a-%b-%d)" ] && [ "$dayOfWeek" = "Sun" ]; then echo "last sunday of th>
#every monday
...
```
_copy this to another day and change `Sun`, `sunday`, and `sunday` to that day. The 2 indicates this will be on the second sunday_
```
Anytime something is `echo`ed it gets added to your calendar. Make sure not to get rid of the section `sunday=$(($sunday+1))` because that is how the program keeps track of which sunday (etc) we're on.
#last sunday
if [ "$(date -v1d -v+"$tooFarNum"m -v-1d -v-sun +%a-%b-%d)" = "$(date -v1d -v+"$1"m -v+"$PLACEINMONTH"d +%a-%b-%d)" ] && [ "$dayOfWeek" = "Sun" ]; then echo "last sunday of the month potluck">> $calendarFile; fi
```
_this one is a liiiitle more complicated but you can copy and paste this one to create events on the last monday/tuesday/etc of the month. Just change "Sun" to a different day of the week_
3. configure calendarchive
@ -85,18 +87,18 @@ and modify them to point to your calendar files. Make sure both those exist at l
## usage
My personal notes folder is plain text synced between machines with SyncThing and edited via Notational Velocity (or sometimes TextEdit, nano, whatever). I keep calendar.txt, calendar_archive.txt and all sorts of other notes in there. I've been calendaring this way since fall of 2019.
My personal notes folder is plain text synced between machines with SyncThing and edited via Notational Velocity or TextEdit or Gedit, etc. I keep calendar.txt, calendar_archive.txt and all sorts of other notes in there. I've been calendaring this way since fall of 2019.
### calendarender
calendarender takes one argument and that's the number of months in the future you'd like to render. So say it's currently a day in November and I want to add the days in January to my calendar.txt, I would run `calendarender 2`. It'll print to the terminal as well as to the file.
calendarender takes one argument and that's the number of months in the future you'd like to render. So say it's currently some day in November and I want to add the days in January to my calendar.txt, I would run `calendarender 2`. It'll print to the terminal as well as to the file.
calendarender also prints relevant moon phases: new, full, crescents and halfs. On any day that isn't one of those phases a sun is printed. If it's waxing an up-arrow will be printed, waning, down-arrow. It's not the _most_ accurate moon-phase algorithm but close enough for me :)
### calendarchive
if you run calendarchive without any arguments it will remove all days from calendar.txt that are before the current day and append them to the bottom of calendar_archive.txt. If it's late at night but before midnight you can run `calendarchive 1` and it'll also archive today as well.
if you run calendarchive without any arguments it will remove all days from calendar.txt that are before the current day and append them to the bottom of calendar_archive.txt. If it's late at night but before midnight you can run `calendarchive 1` and it'll also archive today as well (this doesn't work on linux though because of differences in how the `date` program works. Oh well.).
you could cron calendarchive to have it automatically run but personally I keep all kinds of notes and things in my calendar and don't want to lose track of anything. So I manually run calendarchive.

View File

@ -61,7 +61,10 @@ do
dayOfWeek="$(date -v+"$1"m -v1d -v+"$PLACEINMONTH"d +%a)"
#############render weekly things
############# render weekly things
# SUNDAYS
#every sunday
if [ "$dayOfWeek" = "Sun" ]; then echo "water plants">> $calendarFile; sunday=$(($sunday+1)); fi
#second sunday
@ -71,18 +74,39 @@ do
#last sunday
if [ "$(date -v1d -v+"$tooFarNum"m -v-1d -v-sun +%a-%b-%d)" = "$(date -v1d -v+"$1"m -v+"$PLACEINMONTH"d +%a-%b-%d)" ] && [ "$dayOfWeek" = "Sun" ]; then echo "last sunday of the month potluck">> $calendarFile; fi
# MONDAYS
#every monday
if [ "$dayOfWeek" = "Mon" ]; then echo "contact Bob">> $calendarFile; echo "put recycling out">> $calendarFile; monday=$(($monday+1)); fi
# TUESDAYS
#every tuesday
if [ "$dayOfWeek" = "Tue" ]; then tuesday=$(($tuesday+1)); fi
# WEDNESDAYS
#every wednesday
if [ "$dayOfWeek" = "Wed" ]; then wednesday=$(($wednesday+1)); fi
# THURSDAYS
#every thursday
if [ "$dayOfWeek" = "Thu" ]; then echo "open hours at Lab B">> $calendarFile; thursday=$(($thursday+1)); fi
# FRIDAYS
#every friday
if [ "$dayOfWeek" = "Fri" ]; then friday=$(($friday+1)); fi
# SATURDAYS
#every saturday
if [ "$dayOfWeek" = "Sat" ]; then saturday=$(($saturday+1)); fi