Sunday, May 18, 2008

Java in Ubuntu & Annoying Sound Problem Fixed

After several days of my first free-time (but payed!) coding venture on Ubuntu, in Java with Swing through Netbeans IDE, I've created my first GUI from scratch, and my first program (which edits XML files). Overall, Java with Netbeans is amazingly simple for a newbie to understand -- and the support on the web (tutorials, etc) are amazing. And it works in Ubuntu just as it does on Windows, which makes me happy =)

Tomorrow I start officially at work (not from home), and it will hopefully be filled with more of these ventures.

Annoying Sound Problem

So after enduring a month or so of not being able to have multiple programs play sound (firefox, rhythmbox, vlc, pidgin) at one time, I've somehow managed to get it to dissappear. The source is probably Ubuntu updates, but I can't tell you for sure because I made multiple, random changes before restarting my computer to find it was gone! But, probably, it was the Ubuntu updates. So, keep downloading your updates, people.

The problem was the switch from ALSA to PulseAudio between Gutsy and Hardy. Some programs lingered that wanted to use ALSA (flash player), and ALSA and PulseAudio can't be playing sound simultaneously.

This forum post explained my issue, and provided workarounds (not sure if they work) for many programs.

Sunday, May 11, 2008

Ubuntu Usenet NZB Client & Happy Mothers Day

Ever wonder why you can't find a good Ubuntu NZB Client with a GUI? It's because someone gave it the super creative name of "NZB".

sudo apt-get install nzb


It seems to be lacking some features that I've found useful in command-line programs like Hellanzb — like autounrar and autopar — but it gets the job done.

I'm definitely interested in hearing about any other Ubuntu NZB GUI clients out there, if anyone can give a recommendation.

Happy Mothers Day
To all you people who came from a womb, make sure to give thanks to the holder of the vagina you came out of!

Thursday, May 8, 2008

Baseball Practice & Slow Updates

You know what's awesome? Not having to wait forever for your Ubuntu updates. It's times like this I grow to appreciate living on a campus that is an official mirror for Ubuntu updates, and, while living there, all your updates download with the snap of a finger.

Baseball Practice
Man, I miss being a kid. When the best thing that could happen was a cool activity, or a friend to play with appearing. I took my 5-year-old cousin to baseball practice today. It started to sprinkle and they canceled it before it began, but we were there already. So, we threw the ball around for awhile and played on the playgrounds (kids have AMAZING playgrounds these days) until supper time grew close. I was amazed at how thrilled he was with doing simple things, and I kind of let some of that seep into me, and enjoyed myself immensely. While we drove around, he kept making me play the rock-and-roll music real loud with the windows down. This kid is going places.

It's almost the end of the week. Mother's day is this weekend, and I have a project for work due next Tuesday. Expect blogging to slow down =\

Wednesday, May 7, 2008

Desktop Cube & Netbeans Install

If you have Ubuntu, there's one thing you MUST do, and that's sit in the front row of a boring lecture with your laptop open and make it a point of using applications on ALL four faces of your Ubuntu cube. This way, you'll reach optimum distraction levels with the people sitting behind you.

They changed it up on me in Hardy Heron. Used to, to get your cube working, you'd install "compiz-config-settings-manager," but now it's called "ccsm."

There's also a new settings manager, simple-ccsm, but I still like the thoroughness of the fully featured one.

The Cube in Action


Netbeans in Ubuntu
With Hardy Heron, Sun has ported Netbeans into the official Ubuntu repository! As luck would have it, I just got a project that requires viewing some mock-ups inside it, so this means my Ubuntu relationship is meant to be.


Woops, a fishy error occurred while I tried to run it for the first time, saying something about specifying the JDKHome:
However, it says something about specifying the --jdkhome option, so I looked it up my openjdk's path in the Synaptic Package Manager and started it with that path specified, and voila! So to get past this, make sure you run netbeans like so:
netbeans --jdkhome /usr/lib/jvm/java-6-openjdk
Note: your jdk might be in a different directory. If so, do what I did to find it, just open synaptic package manager in System > Administration > Synaptic Package Manager, and look for a package with jdk in the name. More than likely it will be installed already - just look at its properties (right click) and look under the installed files tab for something ending in "/lib/tools.jar," and then you know that directory before lib is the 'home' you want.

Tuesday, May 6, 2008

My New Ubuntu Dock

For anyone who prefers a dock over the boring default panel at the bottom of your screen, let me introduce the Avant Window Navigator (AWN):


Install: sudo apt-get install avant-window-navigator

To check it out after you install it, hit Alt-F2 and type in 'avant-window-navigator'.

Auto-run
You can set AWN to run automatically on login, just go to System > Preferences > Sessions. And then click 'Add,' and type in the command that runs your program (i.e. 'avant-window-navigator'), as shown below:

Get Rid of Bottom Panel
Like it? Want to get rid of the default Ubuntu panel at the bottom? Just Right Click > Delete This Panel.

Note: If you ever want to reset your gnome panels:
  1. rm -rf ~/.gconf/apps/panel
  2. Log out, and log back in.

Custom Kill Terminal Command

So a program has froze, and you happen to have a terminal handy. Usually, you'd have to do some command to find the Process ID (PID), such as ps -A or top. Then after finding the process ID you'd use the kill [process id] command to kill it. This is usually an annoying task if you have to repeat it alot, an example is shown below:
jake@jakswa-laptop:~$ ps -A
...
14063 ? 00:00:03 notification-da
17215 ? 00:00:03 pidgin
19981 ? 00:22:14 rhythmbox
24794 ? 00:03:40 firefox
26655 ? 00:00:00 sh
26656 ? 00:00:00 gnome-terminal
26658 ? 00:00:00 gnome-pty-helpe
26659 pts/0 00:00:00 bash
26768 pts/0 00:00:00 ps
jake@jakswa-laptop:~$ kill 24794

However, wouldn't it be nice to just say "killname firefox" and have something automate that process? You CAN! This n00b is excited, because he just made a script to do it! If you want to understand what I did, you should know about piping outputs of commands, and maybe something about regular expressions.

The Script
ps -A | grep $1 | sed -e "s/ *\([0-9]*\) .*/\1/" | xargs kill

What does this do? I'll explain it step by step.
  1. ps -A lists every process with PID and name.
  2. the first vertical bar sends every line that ps -A prints (like 24794 ? 00:03:40 firefox) as the input to the grep $1 [input] command.
    So, grep ends up being something like:
    echo "24794 ? 00:03:40 firefox" | grep firefox (search "24794..." for "firefox")
    where $1 is replaced by whatever process we want to kill — 'firefox' in this case.
  3. if grep finds every line that has the search term, 'firefox', and 'pipes' it to the Stream EDitor (sed) command (this is done by the second vertical bar).
  4. The sed command filters out only the PID of the line that was sent to it by grep, and passes that PID onto the xargs kill command.
  5. 'xargs' takes the given PID and uses it as the argument in a "kill" command
Making it a Terminal Command
So maybe you'd like to run this script as any other command in the terminal. Well all we have to do is copy the script to the '/bin' folder. Just make sure you're root:
sudo cp [scriptfile] /bin
Now you can run it in the terminal using the name of the script file.
Example (to kill 'firefox' with script as "killname"):
killname firefox

Voila! This might not be the best way to do things, and I doubt the script is very error proof (don't run it as root, or else you might kill some important processes). Mainly, this was made to become more comfortable with bash scripting.

Cheers!

More info on pipelining: Pipeline (Unix) - Wikipedia
More info on regular expressions: Regular Expressions - Wikipedia

Two-command DVD Playback & Another Semester Done

Where was this article half a year ago when I was first fumbling my way through DVD playback on Ubuntu? I spent a ghastly 3 hours getting a simple DVD disc to play. For which, I have to blame the fact that the DVD format is proprietary, and not included in Ubuntu for that reason. Damn you, propriety!!

Anyways, here's my experience in my fresh install of Ubuntu Hardy Heron (8.04). Type these two commands in your friendly terminal:

sudo apt-get install totem-xine libxine1-ffmpeg libdvdread3
sudo /usr/share/doc/libdvdread3/install-css.sh

Then insert a DVD, and it should play. However, my default open application is Totem, and it struggled to play with some lag on my ancient laptop. In response, I simply opened VLC (if you don't have it installed under your Sound and Video apps: sudo apt-get install vlc) and did a File > Open Disc, checked the 'DVD' box, and away Finding Nemo went.

Boo propriety!! Hooray Ubuntu!

Over the hump?
Another semester at Georgia Institute of Technology (Gatech) is done as of last Friday. Here's a saying that I've grown more and more accustomed to: "Georgia Tech — where your best hasn't been good enough since [forever]."

This last semester will bring the tally to six total semesters, and three years spent in college. And what wisdom do I possibly have to pass on? After three years, what all-encompassing nugget of knowledge can I give you? Wait. Wtf? Don't look to me for that kind of garbage. I'm not going to be responsible for the messed up shit swimming around in your head.

Welcome to Ubuntune

I thought I'd begin this experiment with a little introduction. Hi :)

Who am I?
Let's see. I'm a 20 year old college student who sees his future inside technology, but is caught in a maze finding that future. The maze is big. The student is small, but he's still going! I'm also a coop inside a small technology company in Georgia. If you don't know what a coop is, just think of it as an intern who alternates semesters between work and school, making money while getting a taste of the real world, and — something more recently realized — postponing his inauguration into that real world.

Why a blog?
There are a couple reasons behind this blog, none of which are clearly founded at this time. Speaking of time, I have this summer off from studies, and I don't think this experiment would be possible without that free time. Interests? Lately, I've developed strong interests and ideas in certain areas of technology, and here's an attempt at putting some of those ideas into words. Of course this includes Ubuntu and the world of OSS that it has introduced me to, as well as things dealing with my major — Computer Engineering. It also includes anything else I feel inclined to write about. However, I'll try to keep things focused. Lastly, to be honest, if this blog becomes super popular (which I doubt), then the little ads to the right would be another reason behind this blog.

Sweet.
With that out of the way, let the blogging commence!