Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Even more fun with cal and GeekTool' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Even more fun with cal and GeekTool
Authored by: ennisdb on Jun 28, '04 01:35:08PM

Very nice. I've been using GeekTool since the original post. I'll add the *day* highlighting later. Any advice on displaying selected months? That is, it would be nice to display, the previous, current, and next month. Or perhaps, the next three months. Obviously its easy to display all twelve months, but most often one only needs a few months.



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: groundswells on Jun 28, '04 02:15:55PM

I don't have my Mac out right now, but I assume it works the same as in most unix distros 'cal 7 2004' would display july 2004 or 'cal 12 2004' would display decembers. Maybe I am missing the question.



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: Anonymous on Jun 28, '04 03:37:37PM

No, he's looking to know how to show *multiple* selected months, i.e., "show me June, July, and August." I don't know if you can just go cal 4 5 6 2004, but I doubt it ... although, posting this from a Windows box, I have no way to check ...



[ Reply to This | # ]
'cal 4 5 6 2004' doesn't work
Authored by: the_webmaestro on Jun 28, '04 04:49:53PM

I don't have a solution, but I know that doesn't work...

---
Father of Jeremy Logan Leeds



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: da5idonimac on Jun 28, '04 04:57:24PM

simple. just make multiple windows in geektool, one for each desired month and enter 'cal 6 2004', 'cal 7 2004' and 'cal 8 2004' as commands for the respective months (windows).
now you an drag around the windows and arrange them the way wou want them...
i assume someone smart can create the appropriate shell-commands to create the desired months automagically.



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: ennisdb on Jun 28, '04 05:12:38PM

I had a feeling I wasn't being clear enough. Obviously I can go into GeekTool and change the month range whenever I want. It would be sort of silly to have "cal 7 2004; cal 8 2004; cal 9 2004" unless you only wanted those specific months year round. Conveniently, "cal" alone assumes the current month and year, but there is not an obvious way to output "cal n-1; cal n; cal n+1" where n is the current month which can presumably be obtained from the OS. I'd like to display last-, this-, and next-month without having to hard code "this" month. Is that more clear?



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: ennisdb on Jun 28, '04 05:14:46PM

For clarity, and in response to the earlier points I should add that:

cal 7 2004; cal 8 2004; cal 9 2004;

Provides a suitably formatted output for multiple months...IF you only want those hard coded months.



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: dILVISH on Jun 28, '04 06:38:56PM
Okay, this is crude and awful, but it seems to work. Any better solutions welcome! Anyway, after seeing the post this morning I got all excited, but I wanted to see previous and next month as well. I ended up with a small shell script.


#!/bin/sh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))
lastMonth=$(($month-1))

if [[ $nextMonth -gt 12 ]]
then
	nextMonth=1
	year=$(($year+1))
fi

if [[ $lastMonth -eq 0 ]]
then
	lastMonth=12
	year=$(($year-1))
fi

cal $lastMonth $year
cal $month $year
cal $nextMonth $year



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: dILVISH on Jul 05, '04 09:19:51PM
Well, no one volunteered to improve upon my code, which is too bad. But I *did* make a couple of small improvements that are worth mentioning. This will display the previous, current and next month vertically, with the current date highlighted with parenthesis.

I'm pretty sure the original post from wallybear would have had a problem highlighting the first or last days of the week, so that's been fixed here. I did NOT include the change so the week starts on Monday, I like Sunday.

Here is the code:


#!/bin/zsh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))
lastMonth=$(($month-1))

if [[ $nextMonth -gt 12 ]]
then
        nextMonth=1
        year=$(($year+1))
fi

if [[ $lastMonth -eq 0 ]]
then
        lastMonth=12
        year=$(($year-1))
fi

cal $lastMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); print " "$0; getline; print " "$0; while (getline != 0) {a=" "$0" "; sub(" "fill int(cday)" ",fill "(" int(cday)")", a); print a }}'
cal $nextMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
and here is the output:

     June 2004
  S  M Tu  W Th  F  S
        1  2  3  4  5
  6  7  8  9 10 11 12
 13 14 15 16 17 18 19
 20 21 22 23 24 25 26
 27 28 29 30
 
      July 2004
  S  M Tu  W Th  F  S
              1  2  3 
  4 (5) 6  7  8  9 10 
 11 12 13 14 15 16 17 
 18 19 20 21 22 23 24 
 25 26 27 28 29 30 31 
  
    August 2004
  S  M Tu  W Th  F  S
  1  2  3  4  5  6  7
  8  9 10 11 12 13 14
 15 16 17 18 19 20 21
 22 23 24 25 26 27 28
 29 30 31

Last word on the subject, I promise!

[ Reply to This | # ]

Even more fun with cal and GeekTool
Authored by: wallybear on Jul 07, '04 04:56:32AM

No, my code has no problem marking first or last day of the week, as I added a space before and after each line, in order to make the replace string working everywhere.
Just give it a try...



[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: mrchaotica on Jul 09, '04 01:09:56AM
there's one serious issue with your script: When the month is december or january, it wil display the wrong year, since you only calculate it once. If it's december, you have to call only the next month with "year + 1", and if it's january, you have to call only the previous month with "year - 1" Here's the fix:

#!/bin/zsh

month=`date +%m`
year=`date +%Y`

nextMonth=$(($month+1))
lastMonth=$(($month-1))

if [[ $month -eq 1 ]]
then
        lastMonth=12
        cal $lastMonth $(($year-1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $lastMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi

cal | awk -v cday=`date "+%d"` '{ fill=(int(cday)>9?"":" "); print " "$0; getline; print " "$0; while (getline != 0) {a=" "$0" "; sub(" "fill int(cday)" ",fill "(" int(cday)")", a); print a }}'

if [[ $month -eq 12 ]]
then
        nextMonth=1
        cal $nextMonth $(($year+1)) | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
else
        cal $nextMonth $year | awk '{ print $0; while (getline != 0 ) { print " "$0 }}'
fi


[ Reply to This | # ]
Even more fun with cal and GeekTool
Authored by: DavidRavenMoon on Jun 29, '04 08:30:27AM
Easier than all this, but not as geeky, is Menu Calender

You can switch months, and it has iCal support.

[ Reply to This | # ]