Friday, December 5, 2008

Ubuntu Fanboys Love Apple.

There seems to be a growing trend of Linux users using Macs. Recently it occurred to me that everyone I know who runs Linux on a Mac use Ubuntu. I'm not sure exactly what this means, I just find it interesting. As I pondered about this I began to realize a few other common characteristics of Linux+Mac users (L+Mu) which I would like to share with you. Now please understand that this is just my observation, not an in depth study of any kind.

1. They all run Ubuntu. Don't get me wrong, Ubuntu is a great distro, I run it on my main PC at home, but I also run Slackware 12.1, Fedora 10, PCBSD and Crunchbang! (essentially Ubuntu). It just seems Ubuntu is by far the distro of choice for L+Mu.

2. Not only do they run Ubuntu, but they always dual boot MAC OSX. It doesn't just seem to be a love of Apple hardware for L+Mus, but they also seem to have a fondness for the operating system as well. They seem to boot into OSX and use it. Again, OSX is a good OS, it's just not my cup of tea.

3. L+Mu seem to be this rising new generation of Linux users that began in 2004-2005, around the time Ubuntu first came out. I don't see many "Old School" users turning to Mac. By "old school" I mean pre-2.4 kernel. I started using Linux in 2001 and consider myself a 2nd generation Linux user. The 1st generation of users being from 1991-1997/8, the 2nd generation from 1998-2003-ish and the 3rd generation from 2003/4 on. Each generation seems to have their own characteristics and personalities, which I won't get into this post. Before I get too far topic though, I 'll just say that it seems the trend of L+Mu are newer Linux users.

4. Finally, you don't find too many FOSS purists among L+mu. I guess this is obvious with the simple fact that they are using Apple hardware. Again don't get me wrong, I don't have a shrine to Richard Stallman at home, but I have a respect for GNU and his ideas. Now I believe this is one of the characteristics of this new rising 3rd Generation mentioned above, that they don't seem to see anything wrong with proprietary / close source software. They actually see it as a good thing.

Am I the only one noticing this pattern or am I completely off? Please give me your opinion to this trend of Linux+MAC users.

Friday, November 28, 2008

Your Little Black Book - Using a Text File and grep

This tutorial incorporates grep, nano and awk to search a text file of contacts to create a CLI PIM manager or address book and demonstrates well the power of the CLI. You do not need to have any knowledge of these commands to
follow the tutorial, but an understanding of such commands will aid in understanding the concepts being applied.

This address book and contact manager will have the following characteristics:

  1. be able to search and view records whenever you need them, from the command line and a text editor.
  2. perfectly accessible over a slow text-only network line
  3. be able to cut and paste addresses and contact information from the Web, email, and any other applications
  4. have no concept of "required fields" -- each record can contain as much, or as little, information as you need to have.
  5. can be taken with you and used on any Linux or Unix machine

Creating the Addresses file

The first step is to make a new file (call it something like "addresses"), you can do so by typing:

nano addresses
Now, you can begin adding records to it.

Records have to be delimited somehow; I would suggest putting ### on a line by itself between each set of contact information. Format the records themselves however you like, with name and address and whatever information you have. I used to keep a completely free-form contacts file, so that each record contained completely unformatted data in whatever way that I happened to get it, but this practice quickly shows its limitations -- I've found
that it helps immensely to label certain fields, such as telephone number and email address. I use this format:

Name
Address
Phone: phone number
Fax: fax number
Email: email address
Comments: additional information
As an example, a few records might look like this:

---------------------------------------------------

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net

###

capri pizza
Phone: 555-8250

###

jane smith
Phone: 555-3104
Email: jsmith@example.nyu.edu
Comments: friend of susan's

------------------------------------------------
Searching, browsing, and exporting records

Create the following script to make searching for a contact easy.

#!/bin/sh
awk 'BEGIN { RS = "###" } /'$*'/' ~/addresses
Name the script "contact" and make it executable (chmod +x contact). Make sure that your Address file and your contact script are in the same directory or place the script somewhere within your path.

At the command line simply type:
contact jane

or

./contact jane

This should bring up Jane Smith's contact information as found in the text file. You can search using any of the information in the text file. Here are some examples:

contact nyu.edu
will give you all contacts with a 'nyu.edu' email address.

contact 90028
will give you all the contacts living in the that zip code. You search options are limitless.


More Advanced Searching using grep and awk

fgrep outputs single lines of the file that match a string you give, and is good for when you just want to see if you have such-and-such a record in your file. Use the -i option to do a case-insensitive search -- for instance, here's how to see if you have contact information for Acme
Industries:

fgrep -i 'acme industries' addresses
Should display:

Acme Industries, Inc.
The output gave the name -- but you want the phone number too. Output the search with a few lines after the match with the -A option:

fgrep -i -A5 'acme industries' addresses
Which will display the next 5 lines following the name 'acme industries', like this:

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net
And here's where using labels really pays off. When you need, say, all the email addresses that have "nyu.edu" in them, you can find them with a plain grep command:

$ grep '^Email:' addresses | fgrep 'nyu.edu'
Then you can simply copy and paste the listed emails into your email client.

Harvesting the actual addresses themselves is also a trivial matter:

$ grep '^Email:' addresses|egrep -o '[^ ]+$'
You can use awk to output entire records containing a particular match. The simplest way is to change the awk record separator, RS, to ### and then enclose the pattern to match in slashes. For example, here's how to export all records containing the string "acme" somewhere in the record:

awk 'BEGIN { RS = "###" } /acme/' addresses
and you will get:

Acme Industries, Inc.
4211 E Broadway
New York, NY 10026
Phone: (212) 555-1032
Fax: (212) 555-1038
Email: acme@example.net
The contact script we first used in this tutorial is based off of this awk command.

Because the file has labels, you can limit your search to them. For example, you can search for all email addresses that have "smith" in them, and output the entire records:

awk 'BEGIN { RS = "###"; FS = "Email: " } ($2 ~ "smith") { print $0 }' addresses
You can use the same awk pattern to do any number of things. For instance, in conjunction with the grep examples above you can output all the email addresses in records that have "friend" in the comment field:

$ awk 'BEGIN { RS = "###"; FS = "Comments: " } ($2 ~ "friend") { print }' addresses | grep '^Email:' | egrep -o '[^ ]+$'
Adding and importing records

Adding records to your contacts file is easy. The file doesn't need to be sorted, so append new records by either editing the file in nano or using redirection on the command line:

cat >> addresses
then type in your new contact, like this:

###
new name
Cell: 801-123-4567

This will add the 'new name' to the bottom of your addresses file.

Rarely do I actually type out any new contact information myself -- that only happens when I'm transcribing something from paper, or when I'm getting a number from someone on the phone. Nine times out of 10 I'm just cutting and pasting the text from the Web or email into an editor window that has
the contacts file open. It's painless and fast -- there are no forms to have to fill out for each part of the record. But you have to keep two things in mind: separate the records with hash marks, and insert labels for numbers, email, and comment fields, if you want to use them.

If you already have a set of address records formatted some other way, awk can import it so that it's in the right format.

Let's say you have a file named address.txt where all the records are kept one to a line in this common format:

lastname,firstname,address,city,state,zip,phone,email

Here's an awk one-liner to take that input and spit it out into the bottom of the addresses file, in just the right format:

$ awk 'BEGIN { FS = "," } { print "\n###\n\n" $2, $1, "\n" $3 "\n" $4 ", " $5, $6, "\nPhone: " $7, "\nEmail: " $8 }' address.txt >> addresses
ENJOY!

Disclaimer:
This tutorial is a re-publication from an article from linux.com a few years back with some slight modifications from me. I'm unable to find the original article to link. If anyone knows who originally published this please let me know and I'll make the necessary reference.

Monday, November 24, 2008

Is that a Fish in Your CLI? The asciiquarium Screensaver.

We've all seen the aquarium screensavers with fish swimming around our monitor. Well that calming soothing fish love isn't just for the CLI haters. Command line activists can also go fishing via the terminal with asciiquarium.

asciiquarium is not in the Ubuntu repositories but don't let that scare you. asciiquarium is a perl script which gives us easy access to this fun little program. Before we can see our fishy friends there are some dependencies we need, perl (of course), curses and the Term::Animation module. perl and curses is found in most of Linux distros by default, but I had to install the Term::Animation module from source which was pretty easy on Ubuntu. You can get Term::Animation from freshmeat.net. Just download Term::Animation, uncompress, enter the newly created directory and proceed with the following steps in the terminal,

1. perl Makefile.PL
2. make
3. make test
4. make install


Once installed, download asciiquarium from here, uncompress, enter the newly created directory and type the following.

./asciiquarium



Once running, pressing "r" will redraw the image, "p" will pause the animation and "q" will quit the program.

Watching all these fish are making me hungry. I think I'm in the mood of a good fish taco.

Happy fishing.

Friday, November 7, 2008

How's the Weather up there? CLI weather app.

weather-util gives you local weather readings on the command line. If you are running Ubuntu you can easily install this handy little application by typing the following in the command line.

$apt-get install weather-util
To retrieve local weather information you will need to know your local weather id which can be found at the National Weather Service. Your id is a 4 digit letter code which identifies your city or area. I live in Salt Lake City, Utah and my id is KSLC.

Once you have your id the syntax is fairly straight forward.

$weather -id=KSLC
Which outputs the following:

Current conditions at UT (KSLC)
Last updated Nov 07, 2008 - 09:53 AM EST / 2008.11.07 1453 UTC
Wind: from the SE (140 degrees) at 8 MPH (7 KT)
Sky conditions: mostly cloudy
Temperature: 39.9 F (4.4 C)
Relative Humidity: 62%

You can get a forecast using the -f option.

Current conditions at UT (KSLC)
Last updated Nov 20, 2008 - 08:53 AM EST / 2008.11.20 1353 UTC
Wind: Calm
Sky conditions: partly cloudy
Temperature: 32.0 F (0.0 C)
Relative Humidity: 85%
Issued Thursday morning - Nov 20, 2008
Thursday... Sunny, high 55, 0% chance of precipitation.
Thursday night... Low 30, 10% chance of precipitation.
Friday... Sunny, high 43, 0% chance of precipitation.
Friday night... Low 21.
Saturday... High 45.


Now you have no excuse to be caught out in the cold unprepared. If you can muster up some creative juices I'm sure you could easily get the output to display in conky.

Friday, October 31, 2008

WOW! Ubuntu Intrepid Ibex

Just a brief post on how impressed I am with Ubuntu Intrepid Ibex. I've only played around with the liveCD, but I am definitely well impressed, mostly with it's increased speed. I tested it on an older P4 1.4 Ghz laptop with 512 mb RAM and it was fast, even running from CD. Also, wireless worked. I've been having trouble with wireless on this laptop, with each of the 4 OSes installed (including MS Windows XP). Wireless works great with Ibex. Ubuntu has also had problems with this laptop's Intel i810 video card. I would usually have to manually edit the xorg.conf file, but Ibex handled it like a champ, including compiz.

I'd also like to make a comment on one particular accessibility feature, orca. As some might know, my eye sight is deteriorating, which is increasingly having me become more interested in accessibility options in Linux. Orca is pretty cool. For those who are unaware, orca is a text to speech application. I want to thank Ubuntu for including ocra by default.

Good job guys.

Friday, October 24, 2008

gcalcli - Google Calendar on the Command Line

gcalcli gives you access to your Google Calendar on the command line. You can retrieve your calendar information for multiple calendars and in various formats. gcalcli can be found in the repositories for Ubuntu Hardy and Ibex.

If your Distro does not have gcalcli in it's repositories, instructions can be found here. gcalcli is written in python and just has a few dependencies for an easy install.

Once installed you may need to create a .gcalclirc file in your home directory. The file should be configured like this:

[gcalcli]
<config-item>: <value>
<config-item>: <value>
...

Mine looks like this:

[gcalcli]
user: username@gmail.com
pw: password
cals: all

Obviously, use your own Google Calendar username and password in the file. I have several calendars that follow, like a US Holiday calendar, a family birthday calendar and my Wife's calendar. I wanted to have access to all the calendars so I indicated that as an option in the config file. There are several other options that can be included within this configuration file specifically having different colors for each calendar.

On my laptop running CrunchBang! Linux, gcalcli was not correctly reading
the .gcalclirc file. So, I created the following alias in my .bashrc file:

alias gcalcli = "/usr/bin/gcalcli --user=username@gmail.com --pw=password"

This seemed like a reasonable work around for now.

To view my calendar I simply type:

$ gcalcli agenda


Notice my calendar in blue and my wife's calendar in magenta.
Using the agenda option without parameters will list one week of calendar information. You can include a date range to customize the output.

$ gcalcli agenda 11/15 11/31

This will give you all calendar items between 11/15 and 11/31 of the current year.

To view your calendar in a matrix with borders, type the following:

$ gcalcli calw

The calw option without parameters will display the current week's calendar items. You can add parameters to increase your ranges view.

$ gcalcli calw 3


This will display the current week and the following 2 weeks.

You can post to your calendar as well using the quick option in the following syntax.

$ gcalcli quick "10/31 7 pm Halloween Party"


This will create a calendar for a Halloween Party on 10/31 at 7 pm.
Please see the gcalcli site for more things you can do with this neat little app, including adding calendar items to gnu screen and receiving notices. For all you GUI lovers you can even use gcalcli to display your calendar items in conky.

Now you can do all your scheduling and calendaring on the CLI.

Wednesday, October 22, 2008

Everything Can be Done in the CLI (Mostly)

I love the command line and truly believe that it is an ideal interface for the Desktop. It's speed is unparalleled. It's simplicity and flexibility is far superior to anything that can be done with xorg and any GUI. Mind, I'm not a completely idealistic or ignorant to the advantages of a GUI. I'm a KDE and Openbox fan, but I'm constantly drawn to the sheer power and flexibility of the command line that I feel can never truly be reach by a GUI.

I am also drawn to Desktop applications because it is what I know and use everyday and it is what I find interesting. Most people use a computer as a Desktop. Server administrating my may be interesting to some, but I find it very boring and frustrating. Plus, most sys admin's tasks are done on the CLI anyway.

I passionately feel that nearly all tasks that are done in the Desktop can be done from the CLI. I understand that there might need to be some "work-arounds" or extra steps taken on the CLI to accomplish a similar task in the GUI, yet I think it will be a fun challenge.

This being said, I have begun a list of Desktop tasks and the command line applications or options available to complete those tasks. You can find this list here. This is just a list I've thrown together, which I hope to develop as a much bigger community resource. It is a work in progress which I hope to expand and improve. My vision is to have each application link to a resource of some kind. It may link to a tutorial which explains how to use the application or a link to a script that automates a long or repetitive process. Essentially, I want it to be a resource for users to draw upon to be able to complete any Desktop task in command line.

Please send me recommendations as to how to improve this resource. Help me to fill in the blanks. You'll notice a lot of blanks in the Development section. That's because I'm not a developer. Help me with additional solutions to tasks. Please offer suggestions as to how to improve the layout or organization of the list. I hope to have this hosted on my own website sometime, but for simplicity sake I have it on Google Docs. Please make any other suggestions you see fit.

Ways to make comment:
1. make a comment to this post.
2. email: jared (dot) bernard ((@)) gmail (dot) com
3. twitter: https://twitter.com/moriancumer
4. identi.ca: http://identi.ca/moriancumer

Wednesday, August 20, 2008

Procrastination Brings Forth INX

Well, because of my procrastination with SimplyCLI Desktop, someone else has risen to the occasion. Introducing INX which encompasses the concept I was hoping to achieve with SimplyCLI Desktop and WOW! is it beautiful. I am truly impressed. You can view a slideshow with screenshots here and even video screencast demonstrations here .

So, as of now SimplyCLI Desktop is no more (not that it got much further then the concept stage). I don't see a point in having 2 X-less Linux Desktop distros, plus INX has nearly everything I was hoping to achieve with SimplyCLI Desktop. I say nearly because there are a few things I hope INX will expand upon and could improve. First is the name (though I doubt this will change). SimplyCLI Desktop I think is more marketable. INX is very gnu-geek with the whole acronym thing. Also, I would like to see some tutorials by example integrated into INX. I already have several written. Another thing is an installer. One is being worked on, so I'll need to see how that is going. Finally, I didn't see much in the way of video, image or PDF viewers integrated in the menu interface. Mplayer, fbi and fbgs which facilitate framebuffer would be great additions. Solutions on the CLI for these media types is essentially unknown to most and when demonstrated can be very impressive.

Anyway, I plan to contact the maintainer to see what I can do to help contribute. So in the mean time go check out INX and let me know what you think.

Wednesday, May 7, 2008

Let's Try This Again.

So many things to blog about and so little time. My personal life has become very hectic thus my lack of blogging. My work load at my job has nearly doubled and my wife has taken on a business venture leaving me to have to take care of more things at home including our almost 2 yr old son. In addition to this madness, my wife is about to pop with a new baby we've been cooking, which I foresee even less time spent on hobbies and blogging.

This being said, I think I have resolved the liveCD issue mentioned in a previous blog for my pet project SimplyCLI Desktop. I have yet to experiment with this new process which is explained here. It seems pretty straight forward and makes sense as I've read through the instructions, but I've yet to actually test it. I'm hoping to get to it before the baby comes in the next 2 1/2 weeks.

I've been dying to blog about a few things like KDE4, crunchbang Linux and a few more tutorials and perhaps some day I will, but time moves on and unfortunately blogging is towards the bottom of my priorities at the moment. Nevertheless, I'm still plugging along.

So, to the random person who just happens to fall upon this blog, I want you to know I'm still alive and SimplyCLI Desktop will happen.

Sunday, February 24, 2008

The Perfect irssi Configuration or 3 Apps in One.

I love irssi! I use irssi as an all in one irc, instant messenger and twitter client. Here is how I did it.

IRC
First irssi as an irc client. This is what irssi was originally designed to be. irssi is a console application that can run in screen. You can install irssi by:

sudo aptitude irssi

If you are unfamiliar with irc, then here is a quick explanation and how to.

irc stands for instant relay chat. It essentially gives you access to a chat room. I connect to a few linux irc groups on a regular basis to interact with fellow Linux-ites and to ask questions. Just type irssi at the command line. Once started, You will need to connect to a server. Freenode has tons of interesting irc groups. You can see a list of Freenode irc groups here. to connect to Freenode type the following in irssi:

/connect irc.freenode.net

to join the general linux group, type:

/j #linux

You use esc+# (could also be alt+#) key to move through the irssi 'screens'. (i.e. esc+1 for screen one, esc+2 for screen two, etc)



IM
Now let's set up Your instant messenger in irssi with bitlbee.
Install bitlbee:

sudo aptitude install bitlbee

In irssi, connect to a bitlbee server. There are several servers available, I use the following:

/connect im.bitlbee.org

If this is your first time connecting to bitlbee you will need to register. You may need to move to the newly created bitlbee screen in irssi for the following.

register password

This should be a newly create password, used specifically for logging onto the bitlbee server. To set up your IM accounts.

Use the following as model to add your various accounts:

Yahoo
account add yahoo handle password

AIM
account add oscar MyScreenName MyPassword login.oscar.aol.com

Jabber
account add jabber example@server.com password server.address:port:ssl(?)

MSN

account add msn handle password


Once you have added your accounts, activate your accounts:

accounts on

Save your settings:

/save

To see your buddies type:

blist

To chat, type your buddies name and message,

name: Hello world!

The next time you log on to bitlbee, identify yourself with your new bitlbee password:

identify [password]



Twitter
Finally, Let's get twitter going.

Download the twitter perl script from here and save it to your ~/.irssi/scripts directory as wd.pl. Then install a few dependencies.

sudo aptitude install libjson-perl libdatetime-format-strptime-perl libwww-perl

Next you will need to create the following file ~/.netrc by typing,

nano ~/.netrc

copy and paste the following in the file and save.

# set your username (e-mail address) and password in your ~/.netrc file.
# eg.
# % echo "machine twitter.com login your@email.address password
# yourpass" > ~/.netrc
# % chmod 0600 ~/.netrc
#
my $username;
my $password;
Change $username to your twitter username and $password to your twitter password and save the file. You can find this information in the wd.pl file you downloaded earlier. Once the file is saved, change the permissions of the file.

chmod 600 ~/.netrc

In irssi create an alias,

/alias twit /exec ~/.irssi/scripts/wd.pl $*

and save.

/save

Now twitter away by using the following.

/twit

will update all your friends twits and to post a twit, use the following:

/twit -sv "hello World"

OOOOHHH YEAH! the perfect irssi set up. Now doesn't that feel good.
Learn more about twitter here.

NOTE:  THE wd.pl SCRIPT NO LONGER WORKS DUE TO A CHANGES
WITH TWITTER. I CURRENTLY DON'T HAVE A FIX FOR THE SCRIPT.
I HAVE BEEN IN CONTACT WITH THE DEVELOPER, BUT SEEMS TO
HAVE LOST INTEREST IN THE PROJECT.

Sunday, February 10, 2008

Wixi - A Personal Desktop Wikipedia

I've just discovered this great application wixi. It's a personal wikipedia you keep on your desktop. It comes in handy when you're creating documentation or trying to organize notes. It breaks out entries by pages which can be exported to html for web publishing. Pages can be easily be organized and viewed at a glance with a tree structure layout in a left hand column. The best feature is the search function. You're quickly and easily able to search through your documentation and notes.


Wixi is available for Linux, MAC OS X and that other OS. If you're using Ubuntu, you won't find it in the repos, but never fear, it's easy to install.

First install the dependencies:
sudo apt-get install python-wxgtk2.8 pysqlite

Then download wixi from here and unzip the package.
unzip wixi-1.03-src.zip

Then go into the newly created directory and install.
cd wixi-1.03/
sudo python setup.py install

Now you're good as gold. Just type "wixi" in a terminal or if you're using KDE press alt+F2 for the run dialog box.

When you start wixi for the first time you'll be asked to create a new database where all your information will be stored. Just type the name for your database and you're done.


Click "ok" and start using wixi. Visit the wixi homepage for more information.

Enjoy!

Monday, January 21, 2008

Problems with LiveCD Image.

I've been struggling to create the liveCD image. I've attempted using the remastersys script from Linux Mint which should be compatible with Ubuntu 7.10, but I continue to get a disk drive error that no one else seems to be getting.

I'm in the process of looking for the best way to create my image for SimplyCLI Desktop, but I seem to be extremely busy lately with work, teaching, family and church. Needless to say it's going slowly. I'm an accountant and this is our year end wrap up at work, so there is a lot of over time and going in on Saturdays. Things should slow down mid-February. So posting will be spotty until then. If anyone is actually reading this catch the RSS feed at the bottom of the page.

Cheers!