Linux.com

Feature

CLI Magic: When

By Joe Barr on April 03, 2006 (8:00:00 AM)

Share    Print    Comments   

User Level: Beginner

If you're the type of geek who likes tools and apps that are fast and lean, and you're not afraid of getting a little CLI under your fingernails, When is a good choice for your personal calendar. Even better, it's easy enough to install and use, and well enough documented, that you don't have to be a geek to take advantage of it.

In many Debian-flavored distributions, installation is as easy as sudo apt-get install when. You can also find the When source code, Debian, and Gentoo packages on the project's homepage. When is written in Perl and does not require compilation, so installation from source code is easy for anyone who can find their way to the command line. Simply untar the download and enter the resulting directory:

tar xzf when.tar.gz
cd when_dist

Then, as root, enter make install. That's all there is to it. If you get lost, you can get a refresher on the installation process by entering when --help from the when_dist subdirectory. Speaking of help, the man page resulting from the install is your main source of documentation. Unless you read Perl, that is, in which case you can simply view the source code.

Usage

The first time you run when, run it with the e parameter:

when e

That will create a ~/.when subdirectory that contains two key files files -- calendar and preferences -- and also let you choose an editor to use in the future, if you don't care for the default editor, whose name shall be left unspoken so as not to rile the great hordes using it or its rival products, an event certain to bring forth yet another meaningless yet compelling tsunami of flamage which will convince neither side that they hold the wrong position yet bore everyone else to a near-death experience.

Now you're ready to start entering events in your calendar. To enter a LUG meeting for 7 p.m. on March 30, type when e, which will now start the editor you picked earlier, enter 2006 Mar 30,7PM LUG Meeting, and save the file.

Later, when you've forgotten what's on your schedule, just enter when at the command line. When will display the current date and time, plus any events on your calendar for the next 14 days:

Thu 2006 Mar 30   11:14

Thu 2006 Mar 30 7PM LUG Meeting

But what if your LUG meets every week? You certainly don't want to have to enter the same line 52 times a year. Start When with the editor option again, remove the first entry, and replace it with one that looks like this:

w=Thu,7PM LUG Meeting

Now when you check your calendar, you'll always see it listed, like this:

Thu 2006 Mar 30   11:23

Thu 2006 Mar 30 7PM LUG Meeting Thu 2006 Apr 6 7PM LUG Meeting

Only two weeks' worth are shown, because the default "window" for calendar events is 14 days. Remember the preferences file that was created during installation? You can change the default window and other things there. Let's start by taking a look at what is in our preferences file right now:

calendar = /home/warthawg/.when/calendar
editor = vi

The default window for items to appear in our calendar is one day into the past and 14 days into the future. We can change that window simply by adding some lines to the preferences file:

past=-7
future=21

Now when we invoke when, the calendar shows this:

Mon 2006 Mar 27   11:50

Thu 2006 Mar 23 7PM LUG Meeting Fri 2006 Mar 24 Basketball game at 3PM Sat 2006 Mar 25 Feed the donkeys at 2PM Thu 2006 Mar 30 7PM LUG Meeting Thu 2006 Apr 6 7PM LUG Meeting Thu 2006 Apr 13 7PM LUG Meeting

Be sure to enter the minus sign in front of the number of days in the past, or your results will not be as expected.

Instead of changing the default behavior when you want to see more or less of the calendar, you can also use command line options to indicate that you want to see a calendar for specific periods. The w, m, and y options allow you to request a report on all activity for the coming week, month, or year instead of simply for the default window.

Just need to see when a specific date falls on the calendar? Use the c to get the previous, current, and next month's calendar:

$ when c
------February-------  --------March--------  --------April--------
 S  M  T  W  T  F  S    S  M  T  W  T  F  S    S  M  T  W  T  F  S
          1  2  3  4             1  2  3  4                      1
 5  6  7  8  9 10 11    5  6  7  8  9 10 11    2  3  4  5  6  7  8
12 13 14 15 16 17 18   12 13 14 15 16 17 18    9 10 11 12 13 14 15
19 20 21 22 23 24 25   19 20 21 22 23 24 25   16 17 18 19 20 21 22
26 27 28               26 27 28 29 30 31      23 24 25 26 27 28 29
                                              30

When has a few more tricks up its sleeve, both as command line arguments and options. I refer you to --help and man entries to further your command of When.

Share    Print    Comments   

Comments

on CLI Magic: When

Note: Comments are owned by the poster. We are not responsible for their content.

apt-get install did not work - any ideas why?

Posted by: Anonymous Coward on April 04, 2006 02:22 AM
I use Kanotix 2005-4. I tried getting 'when' but here is what I got:

root@1[knoppix]# apt-get install when
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package when
root@1[knoppix]# apt-get install When
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package When
root@1[knoppix]#

why is this happening? The Kanotix sourcelist includes all the Debian packages:

# Unstable
deb <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org> unstable main contrib non-free
deb-src <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org> unstable main contrib non-free

# Testing
deb <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org> testing main contrib non-free
deb-src <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org> testing main contrib non-free

# Experimental
#deb <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org><nobr> <wbr></nobr>../project/experimental main contrib non-free
#deb-src <a href="http://ftp.de.debian.org/debian" title="debian.org">http://ftp.de.debian.org/debian</a debian.org><nobr> <wbr></nobr>../project/experimental main contrib non-free

# Kanotix
deb <a href="http://kanotix.com/files/debian" title="kanotix.com">http://kanotix.com/files/debian</a kanotix.com> sid main contrib non-free
deb-src <a href="http://kanotix.com/files/debian" title="kanotix.com">http://kanotix.com/files/debian</a kanotix.com> sid main contrib non-free

Any ideas how I should get the where.deb package?

#

Re:apt-get install did not work - any ideas why?

Posted by: Anonymous Coward on April 04, 2006 02:32 AM
Don't know if this will help. When I downloaded the source code, the link was 'when.tar.gz', but the name of the file that got saved to my hard drive was 'when.tar.tar'. Once I corrected the filename, things got better.

#

Re:apt-get install did not work - any ideas why?

Posted by: Anonymous Coward on April 04, 2006 02:52 AM
well, apt-get install should fetch a *deb package and not a tar.gzed one.

Bruce! Any ideas?

#

Re:apt-get install did not work - any ideas why?

Posted by: Anonymous Coward on April 04, 2006 03:05 AM
"when" doesn't appear to actually be in the debian repositories (<a href="http://packages.debian.org/cgi-bin/search_packages.pl?keywords=when&searchon=names&subword=1&version=all&release=all" title="debian.org">http://packages.debian.org/cgi-bin/search_packag<nobr>e<wbr></nobr> s.pl?keywords=when&searchon=names&subword=1&versi<nobr>o<wbr></nobr> n=all&release=all</a debian.org>).

#

What makes it better than "cal" and "calendar"?

Posted by: Anonymous Coward on April 04, 2006 06:52 AM

For ages, the standard command-line tools for doing this sort of thing were <tt>cal</tt> and <tt>calendar</tt>. The <tt>cal</tt> program prints calendars. If you want the three-month view, you can simply use <tt>cal -3</tt>, or you can as for a whole year with <tt>cal -y</tt>.




For tracking calendar/diary items, the <tt>calendar</tt> program (in Debian's "<tt>bsdmain</tt>" package, IIRC) offers a similarly formatted file stored in your <tt>~/.calendar/calendar</tt> file. It has the ability to enter repeating items, use relative dates ("three days after 8/28/2006"), be used to mail your calendar via a <tt>cron</tt> job, and comes with a large selection of pre-existing calendars you can merge with your own...various holidays, birthdays, world events, etc.



So my question is "What does <tt>when</tt> offer that <tt>cal</tt> and <tt>calendar</tt> don't?"



-gumnos



#

"These are mastershalums."

Posted by: Joe Barr on April 04, 2006 10:08 PM


One of the most wonderful things about Linux/Unix is that there is no single canonical solution: there is always more than one way to do something.


When I wrote about cal and calender (see this old <a href="http://docs.linux.com/article.pl?sid=04/03/19/0252221" title="linux.com">column</a linux.com>, I didn't assert that they were better than When, and I don't say now that When is better than they are.


I just celebrate the abundance of solutions.

#

Why must every calendar program on Unix

Posted by: Anonymous Coward on April 04, 2006 08:58 AM
use it's ** own ** configuration file ???

#

Re:Why must every calendar program on Unix

Posted by: Anonymous Coward on April 04, 2006 09:00 AM
I mean ** configuration file format **. Why can't they use the standard<nobr> <wbr></nobr>.calendar format ?

#

Pain

Posted by: Anonymous Coward on May 30, 2006 02:13 AM
[URL=http://nervepainrelief.jeeran.com/painrelief<nobr>.<wbr></nobr> htm] Nerve pain relief [/URL]
[URL=http://www.back.painreliefnetwork.net/lowbac<nobr>k<wbr></nobr> pain.htm] Low back pain [/URL]
[URL=http://blog.gala.net/uploads/painreliefback/<nobr>b<wbr></nobr> ackpainrelief.htm] Back pain relief [/URL]
[URL=http://www.weblog.ro/usercontent/13155/profi<nobr>l<wbr></nobr> es/kneepainrelief.htm] Knee pain relief [/URL]
[URL=http://www.info.painreliefnetwork.net/Pain-R<nobr>e<wbr></nobr> lief.html] Pain relief [/URL]
[URL=http://www.sitefights.com/community/scifi/pa<nobr>i<wbr></nobr> nrelief/painreliefpreved.htm] Pain relief [/URL]
[URL=http://www.info.painreliefnetwork.net/Medica<nobr>t<wbr></nobr> ion-Pain-Relief.html] Medication pain relief [/URL]
[URL=http://www.info.painreliefnetwork.net/Natura<nobr>l<wbr></nobr> -Pain-Relief.html] Natural pain relief [/URL]


[URL=http://painrelief.fanspace.com/index.htm] Pain relief [/URL]
[URL=http://lowerbackpain.0pi.com/backpain.htm] Back Pain [/URL]
[URL=http://painreliefproduct.guildspace.com] Pain relief [/URL]
[URL=http://painreliefmedic.friendpages.com] Pain relief [/URL]

#

pal

Posted by: Anonymous Coward on April 05, 2006 12:57 AM
<a href="http://palcal.sourceforge.net/" title="sourceforge.net">pal</a sourceforge.net> is a pretty good color replacement for cal, calendar, and gcal. It lets you make HTML and LaTeX calendars and can import/export to<nobr> <wbr></nobr>.ics format.

#

Where is When

Posted by: Joe Barr on April 04, 2006 04:49 AM

Looks like when is not part of the Debian repositories. Use the alternate instructions from the article to download and install it. It's very easy.

#

Nice little program!

Posted by: Administrator on April 14, 2006 12:26 AM

For my use, it is more practical
than Kontact.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya