My simple calendar script

As some of you know from previous posts, I use JWM as my default window manager. I like to keep things simple and cut down on wasted resources. This helps a lot, as I often run Qemu, Aqemu, or compile Android variants on my older laptop, which is not exactly a resource gold mine. One of the things that I wanted, however, was a lightweight calendar that I could click on and bring up. The original solution was to open up a terminal and simply type “cal”, but that got a little tedious, especially when I already was using the terminal for compiling or something like that.

Eventually, I decided to instead add a shortcut to my JWM start bar, and have that open up a terminal that will run the calendar program for me. The great thing about using a script was that I could specify the colors of the calendar (changing the look), and then give myself an options menu. To make this work with the color, font, or other changes, I actually have the JWM button refer to this first script, by adding this to my .jwmrc file:

[CODE]
<TrayButton popup=”Calendar Script” icon=”web-google-calendar.png”>exec:/home/alaskalinuxuser/Documents/scripts/xcal.sh</TrayButton>
[/CODE]

Then, at that location, I have this simple first script:

[CODE]
#!/bin/bash

xterm -fg black -bg white -e sh /home/alaskalinuxuser/Documents/scripts/cal.sh
[/CODE]

Which in turn runs this script:

[CODE]
#!/bin/bash

cal

read -p “Would you like a different month? Choose a number or choose (n): ” yn
case $yn in
[1]* ) cal -m jan;;
[2]* ) cal -m feb;;
[3]* ) cal -m mar;;
[4]* ) cal -m apr;;
[5]* ) cal -m may;;
[6]* ) cal -m jun;;
[7]* ) cal -m jul;;
[8]* ) cal -m aug;;
[9]* ) cal -m sep;;
[10]* ) cal -m oct;;
[11]* ) cal -m nov;;
[12]* ) cal -m dec;;
[n]* ) exit 0;;
* ) echo “Please choose 1-12.”;;
esac
echo “I’ll give you 10 seconds to read it.”

sleep 10

exit 0
[/CODE]

Here is an example taken from one of the terminals after clicking on it.

[CODE]
June 2016
Su Mo Tu We Th Fr Sa
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

Would you like a different month? Choose a number or choose (n): 2
February 2016
Su Mo Tu We Th Fr Sa
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

I’ll give you 10 seconds to read it.
[/CODE]

I played around with the colors and settings for a while. I think that I have it tuned for what I like, but others may wish for something else. Essentially, I found that if I open the calendar, I almost always want to see the current month, so that is the default. Sometimes, however, I found that I wanted a different month. So the script asks you if you want a different month by month number. After choosing another month, or selecting no, the window will close after 10 seconds of viewing. Usually that is ample time for me to look at what I wanted to see. Obviously the time could be adjusted. Perhaps more obviously, there are GUI built in calendar applications that probably work 100 times better for the average person. This just works for me.

Linux – Keep it simple.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s