Category Archives: Uncategorized

How to Take Timed Screenshots in Linux

0
Filed under Uncategorized

A couple of days ago, I had need to write a BASH script that would take a screenshot once a minute and save it for my later review. This is what I came up with:

while [ 1 ];
do
scrot ./`date +%F_%k.%M`.png;
sleep 60;
done

The script starts by creating never-ending while loop. The scrot command takes a screenshot and saves it in the current working directory as the current date and time (e.g. 2011-03-15_18.56.png). The sleep command causes the script to pause for 60 seconds before looping again.
This script will run indefinitely until it is killed (I run it in a terminal and kill it by hitting ctrl+c).

Diaspora Buttons

3
Filed under Uncategorized

If you use a social network such as Facebook and haven’t looked at Diaspora yet, you should have clicked that link and never read this far. Diaspora is open source social network software designed to allow users to share information while protecting their privacy.

There are a couple of ways to try Diaspora. The easiest way is to know someone already on the network who can invite you. If you don’t know anyone with invites to give away, you can head over to the Diaspora website and sign up to get an invitation.

Diaspora will get better as more people learn about it; so I want to do my part to spread the word. I’ve created a button to put in my blog’s sidebar and a few more to place elsewhere. Here they are:

With all this greyscale, I figured it would be a good idea to throw in some color.

A couple of things to note:

  1. I’m no graphics designer.
  2. I’m not using the official Diaspora font in these. It’s close, but not exact. I hope to get my hands on an SVG of the official logo and redo these buttons correctly.

These are better than nothing, but there is certainly room for improvement. Feel free to leave your constructive criticism in the comments section below. If you have any ideas for slogans, please leave those as well.

I’ve packed these PNGs and their source SVGs in a zip file here.

Monitoring Mobile Broadband Bandwidth Usage

0
Filed under Uncategorized

A while back, I blogged about how I connect to Verizon mobile broadband in Lubuntu. Now that I am connected, I have to worry about the monthly 5GB/month limit enforced by Verizon. In order to avoid the very high overuse fees, I must carefully monitor my bandwidth usage.

I’ve chosen the easy to set up vnstat to monitor bandwidth and vnstati to output the stats as an image. Installing vnstat and vnstati in Ubuntu is as simple as:

sudo apt-get install vnstat vnstati

Once vnstat is installed, I must tell vnstat to start monitoring my network interface. For my mobile broadband setup, the interface is ppp0.

sudo vnstat -u -i ppp0

After running that command, I rebooted to make sure the vnstat daemon was running.
Now vnstat is storing network usage information in a database. But how can one see this information in an easy-to-understand form? This command will output an image with a nice graph showing daily bandwidth usage:

vnstati -i ppp0 -o ~/vnstat.png -d

Of course, I don’t want to run that command every time I want to see up-to-date stats. So I create a cron job to run the command every five minutes by running

crontab -e

copying

0,5,10,15,20,25,30,35,40,45,50,55 * * * * vnstati -i ppp0 -o ~/vnstat.png -d

into the editor, and then saving the file.

Cron will immediately start doing its thing and within five minutes an up-to-date image will appear in the home folder.

For convenience, I have made file:///home/mac9416/vnstat.png my home page in Firefox. When I want to check the latest stats, I simply refresh the page.

http://mac9416.com/2010/06/12/connecting-to-verizon-mobile-broadband-in-ubuntu-10-04/

Adding | Separators Between Vertical Menu Items Using CSS

1
Filed under Uncategorized

The content and design of a web page should be coded separately. Content should be in HTML and design in CSS.

That’s why I cringed when I saw the code for this navigation menu:

Home|About|Around

<a href="#">Home</a><span class="separator">|</span><a href="#">About</a><span>|</span><a href="#">Around</a>

.separator {
margin-left: 3px;
margin-right: 3px;
}

Not only are the separators coded in HTML, but the spacing around them are in CSS. So without CSS, the content looks like this:

Home|About|Around

That’s not very search engine or screen reader-friendly.

So what needs to be changed?

  • The links should be coded as an HTML list. This is standard for navigation menus.
  • The separators should be coded in CSS since they are only useful for visually separating the links.
  • And, just to make things hard, the new menu should appear exactly as the old one.

First, we must put the items in a list.

<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Around</a></li>
</ul>

Now, that’s a menu! But it doesn’t look anything like the original. Let’s line those links up vertically.

li {
display: inline-block;
}

Now for the fun part: adding the separators.

li:before {
content: " | ";
}
/* But we don't want the separator before the first item! */
li:first-child:before {
content: none;
}

Brilliant, eh? It looks just like the original menu, but is now coded well.

Ubuntu Stack Exchange Enters Public Beta

0
Filed under Uncategorized

A week ago, the concept of a Stack Exchange was completely foreign to me. I had used many traditional forums before, and I have been fairly active on Ubuntu Forums. But, excited to try something new, I committed to participate in the private beta of the proposed Ubuntu Stack Exchange.

Over the past week, I have asked three questions, answered twenty-one questions (four were accepted), and earned over seven hundred reputation points. I’ve added a sidebar widget to promote the Exchange and show off my stats.

My Ubuntu Stack Exchange stats

I have learned that the biggest difference between an Exchange and a forum is the intensity level. A forum is very laid-back because there is not much at stake. If you write a bad question or answer, people simply ignore it. Unless you are obnoxious, you’ll do just fine.
On a Stack Exchange, you are awarded for your good effort and punished for your lack of it. This makes stepping on toes inevitable, but in my opinion it makes for a more productive community.

It’s a trade-off, and there will be many people using both. I’ll continue to use both for the foreseeable future, though I’ll probably start asking more questions on the Exchange than the Forums.

The public beta begins in ten minutes, so go over to the Ubuntu Exchange and try it for yourself!

Lightening the Ubuntu Tennessee Website

0
Filed under Uncategorized

A few months ago, LoCoTN member netritious and I created a WordPress theme for the Ubuntu Tennessee LoCo website that looked like this:

Old Ubuntu Tennessee Website

Of course, it wasn’t long after we created that theme that new Ubuntu “light” look came out and it was time to redesign the theme. When I finally got around to it a couple of weeks ago, I basically copied the look of the current Ubuntu website, only using dark purple instead of orange, which I think makes it more elegant and easier on the eyes.

New Ubuntu Tennessee Website

The new theme is easily identified as an Ubuntu site, but it is unique enough to not blend into the crowd.

You can download the new theme from the Ubuntu Tennessee website. There is a link to the zip file in the footer.

Connecting to Verizon Mobile Broadband in Ubuntu 10.04

4
Filed under Uncategorized

About a week ago, I mustered up the courage to replace Ubuntu 9.10 on my laptop with lubuntu 10.04. Overall, the transition was quite smooth. The biggest problem I encountered was not being able to connect to Verizon mobile broadband with my PC5750 card.

A few days before I installed lubuntu, I had read on the Keryx forums that someone had similar trouble in Ubuntu Studio 10.04. They solved it by installing the latest usb-modeswitch and usb-modeswitch-data packages from the Debian repositories. This was, of course, the first thing I tried. But there was no apparent improvement; the Network Manager applet still failed to show the device.

So I went to UbuntuForums with the problem. One kind soul pointed me to a 3G tutorial on backtrack-linux.org. My first attempt to follow the directions was successful. But I was unable to do it again the next day.

In desperation, I decided to learn how to connect to my device “by hand” with GnomePPP and, later, wvdial. That is what you are about to learn how to do.

Gathering Materials

You will, of course, need a Verizon USB or PC card modem. Mine happens to be an Audiovox PC5750.

As for software, you will need either GnomePPP or wvdial. Neither come with lubuntu 10.04, so I had to install them with Keryx. If you only plan to use the command line to connect, you’ll only need wvdial.

Finding Your Modem’s Device Path

Both GnomePPP and wvdial will need the device path of your modem. To find it, remove the modem and plug it back in. Then open a terminal and run dmesg.

$ dmesg

Towards the end of the output, you will see some messages indicating that a device has been detected. The output will include a device path starting with “/dev/”. Mine is “/dev/ttyACM0″.

dmesg Output

Connecting With GnomePPP

Now that you have GnomePPP installed and your modem’s device name written down somewhere, you can start connecting.

Hit <alt><F2> or open up a terminal and run ‘gksu gnome-ppp’.

Starting GnomePPP

After providing your password, you will see a simple dialog where you will enter your connection information. Enter ‘none’ in the Username and Password fields. (Apparently they are required, but have no effect on the connection.) If you’d rather not have to type “none” in the password field next time you connect, check “Remember password.” Then enter #777 in the number field. I’m not sure why that is the number. It just is. :-)

GnomePPP Connect Window

Now you’ll need to give GnomePPP some details about your device. First click the Setup button. At the top of the window that appears, there will be a Device field. Enter the device path you found earlier (again, mine was /dev/ttyACM0). Next, click the device Type dropdown and choose USB Modem.

GnomePPP Connection Setup

That’s all the advanced configuration you’ll need. Click “Close,” and then click the Connect button. After about ten seconds, you will be given a friendly prompt announcing that you are connected, and a timer will start counting the time you remain connected.

GnomePPP Connection Timer

One more thing you should look at is GnomePPP’s connection Details window. On the connection timer dialog, click “Details.” In the Details window you’ll find some very useful information. Most important to me (and I suspect many Verizon customers) is the bandwidth usage. Since Verizon enforces a 5GB per month bandwidth cap, it’s important to keep an eye on that number.

GnomePPP Connection Details

Connecting With wvdial

wvdial is the command-line tool that GnomePPP acts as a wrapper for. Using a command-line tool will allow you to create a connection script so you won’t have to open GnomePPP when you want to connect.

Once you have wvdial installed, you need to create a configuration file to give wvdial the information it needs to connect. Pop open your favorite text editor and enter this information:

Modem = <your device>
Phone = #777
Username = none
Password = none

Replace <your device> with the device path you found earlier. Mine reads “Device = /dev/ttyACM0″.

wvdial Configuration

Save the new configuration file in your home directory as wvdial.conf.

Connecting is as simple as running one command.

$ sudo wvdial --config=$HOME/wvdial.conf

After about ten seconds, it will tell you that it’s connected and list a slew of IP addresses.

wvdial Output

If you are, like me, too lazy to run the command to connect every time you start the computer, you can create a script to do it for you. Just open your text editor again and add the following lines.

#!/usr/bin/sh
gksu 'wvdial --config=wvdial.conf'

Then save the file to your desktop as “VerizonConnect”. Edit the file properties with your file manager or run the following command to make it executable.

$ chmod +x $HOME/Desktop/VerizonConnect

Now when you start the computer, all you have to do is double-click the script on the desktop and provide your password. Remember to give it a few seconds to connect before trying to load anything in your browser.

That’s it! You now know how to connect to your Verizon PC5750 (or similar) device in Ubuntu 10.04 with either GnomePPP or wvdial. If you have any questions, corrections, or requests for clarification, please leave a comment!

My First Acire Snippet: MessageDialog

0
Filed under Uncategorized

Working on the new GTK interface for Keryx last week, I found that I needed a simple Yes/No dialog. I had used stock dialogs in wx, but I didn’t know if the same thing existed in GTK. So after some Googling and reading through mailing list logs, I found that what I was looking for was called MessageDialog. Then I had to search for documentation on how to use it. The documentation I found what fairly verbose and I had trouble understanding it. But after forty-five minutes or so I was rocking away with MessageDialogs.

I could have kept my new hard-won knowledge to myself and continued on my merry way, but instead I decided to share it. When I discovered MessageDialog, I had, of course, looked for an Acire snippet, but there was none. So I made one.

When you run the snippet, you’re given a list of MessageDialog’s options — flags, type, buttons, and message_format. In the screenshots I chose the gtk.DIALOG_DESTROY_WITH_PARENT flag, the gtk.MESSAGE_ERROR option, the gtk.BUTTONS_OK option, and a quote from 2001: a Space Odyssey for message_format.

MessageDialog Acire snippet

When I click ‘Launch my MessageDialog!,’ I am given a nice-looking dialog with an error icon, my message, and an OK button.

MessageDialog Acire snippet

When I click ‘OK,’ I am informed that my response was affirmative.

MessageDialog Acire snippet

That’s it, my first Acire snippet. Look for it in the next Acire release!

Hello world!

2
Filed under Uncategorized

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!