Jan 19, 2012

Linux Firewall Status Indicator

Keywords: KDE, systray, firewall, status, indicator, on/off
Depends on RPM(s) - openSUSE: kdebase4-workspace (for ksystraycmd), xorg-x11 (for xmessage)
Download:  fw_status, fw_on.png fw_off.png

For convenience, when my laptop is plugged into my home network, its firewall is disabled.  When I take it on the road, I switch on its firewall.  What I was missing was a simple icon in my system tray to indicate the status of my firewall.

This script (and the two images) works in KDE (and should be easily tailored for other Window Managers).

After downloading the script and images, place the images in a sub-directory under $HOME (e.g. ~/src/image).  Next, edit the script and change IMG_DIR to point to the image directory which contains the downloaded images.

For me, when I'm on the road, I use the https-everywhere add-on for Firefox.  The script reminds me to re-enable it when I turn on the firewall (and disable it when I've turned off the firewall).  To suppress this message, set RUN_HOOK to 0.  If you'd like to have a different message displayed, change ENABLED_HOOK_MSG and DISABLED_HOOK_MSG accordingly.

Jan 18, 2012

Migrate kmail to thunderbird (convert maildir to mbox) preserving subfolders

Keywords: convert, migrate, kmail, thunderbird, maildir, mbox, hierarchy, tree
Depends on RPM(s) - openSUSE: procmail (for formail)
Download:  do_maildir2mbox

I used kmail for a while (not zillions of years mind you) and had it tweaked to meet my needs.  I didn't particularly care that the developers had decided (for me!) that I couldn't send HTML messages (there are valid times to do so) but I lived without that capability.

With kmail2 though, I couldn't get it to behave.  I struggled over many hours trying to import my kmail mail.  In the end, I did some research and switched to Thunderbird.  With add-ons, Thunderbird is quite awesome.

I wrote a shell script which calls formail to convert kmail's maildir format to mbox.  I found the information on the Web.  I wish I could remember the site so I can properly credit the author.  Suffice it to say, it wasn't me who came up with the idea of using formail.

The script is not what I would call production quality however it is useable.  It converts an entire maildir hierarchy into the corresponding mbox hierarchy.  Edit the script and change SRC_ROOT to point to the top-level directory/folder.  Also, if you have more than one drive, you should set TARGET_ROOT to another drive (for speed), otherwise, you can set it to a location with sufficient disk space.

The script does not handle single folder maildir files.  For these, you can manually convert them - see the formail call toward the end of the script.  Single folders (not hierarchies) are trivial to convert.

Ah, one other item, the script only converts information which is cur therefore ensure you have no new messages.  I'd suggest before starting, POP3'ing your mail, put kmail offline and start.  Try a few runs before taking the plunge.

Jan 14, 2012

Running in cold weather and/or snow

Keywords:  running, cold weather, snow

Running shoes typically have a mesh toe-box to allow air to cool the forefoot.  When running in snow or cold weather, this is not desirable. 

To keep your feet warm, cover the toe-box with a piece of duct tape.  Ensure the shoe is warm and dry before applying the duct tape or it won't adhere.

Jan 12, 2012

Force a refresh when vnc'ing

Keywords:  vncviewer, krdc, Linux

Have you ever vnc'd to a server and needed to force a refresh to remove some graphic artifacts?  To force a refresh, rapidly press the left ALT key three times.

Jan 11, 2012

Hide mouse cursor after non-activity

Keywords:  hide inactive mouse cursor
Depends on:  unclutter

unclutter is an X utility which makes your mouse cursor disappear after -idle seconds.  If you have a jittery mouse (the cursor moves slightly while at rest), you can use the optional parameter -jitter to specify the number of pixels to ignore.

Start unclutter at session start.

Jan 8, 2012

Thunderbird - compose mail wrapper

Keywords:  thunderbird, compose, command-line, cli, wrapper
Depends on:  thunderbird
Download:  send_msg

I found Thunderbird's -compose options a bit cryptic and non-Unix'y.  This script wraps the -compose with mnemonic switches and adds a bit of smarts when attaching (a) file(s).

I use this script both from the CLI to quickly attach one or more files as well as from KDE's Application Launcher.

 Updates
  •  Fixed bug which didn't allow for multiple -b/-c/-t calls.

Jan 5, 2012

KDE - lock screen from the command line

Keywords:  bash, KDE 4, KDE 3
Depends on:  KDE
Download:  lock_screen

Lock your KDE session via the command line or use the Application Launcher to run this script.  Credit, I believe, to Kevin K.  I'm nearly certain he provided the magic juju beans for this script.

If you need to use this script with KDE 3, comment/uncomment the self-evident calls.

Consistent e-mail sound alerts with Thunderbird

Keywords:  Thunderbird, new mail, sound, alert
Depends on RPM(s) - openSUSE:  sox
Thunderbird Add-on(s):  FiltaQuilla

Download:  email_ding, ding.wav

When I converted from Kmail2 to Thunderbird I noticed the New Mail sound alert wasn't consistent.  It'd work mostly.  Slightly maddening.

First, I disabled global sound alerts via the General tab found in Edit > Preferences > General - see When new message arrive:

After installing the add-on FiltaQuilla, I created a new message filter (Tools > Message Filters ...) for each of my e-mail accounts.  The filter is created as follows:
  • Check Match all messages
  • Under Perform these actions:, choose Run File and enter the path of where the script is placed.
You will need to configure the following variables in the script:
  • SOUND_FILE = the sound to play.  You can download the cruddy sound I use.
  • SOUND_PLAYER = the player which will play $SOUND_FILE
  • THRESHOLD = if you get a lot of e-mail in one shot and would like to hear a ding every N seconds, you can set this value to N.

Jan 3, 2012

Manually turn off your display

Keywords:  bash
Depends on:  xset
Download:  screen_off

A simple shell script around xset to turn off the display.

sleep four seconds before switching off the display to allow a remote connection (e.g. VNC) to mouse out of the window, to terminate the remote session.  Usually, VNC'ing doesn't require turning on the display but for KDE, it may be necessary so the screen saver doesn't kick back on.

Ordinal position to spreadsheet column

Keywords:  bash, spreadsheet, spreadsheet column, positional column, mapping, Excel, Libre Office
Depends on:  awk
Download:  ss_col

As a database engineer, I get data in different formats to ingest.  Many times it's in a spreadsheet with many columns:  200+.  During validation, I need to review certain columns.  I may have the column number which needs to be translated to a spreadsheet column (e.g. column number 26 maps to spreadsheet column `Z').

This script prints a column number and its corresponding spreadsheet column.  It's best to pipe the results to a pager such as less.

Jan 2, 2012

Running scripts on Windows

My Host Operating system is Linux (all my Window's needs are Virtualized using VirtualBox).  The scripts found on my blog have been tested on Linux and at times, also on Unix. 

For those folks who'd like to run the scripts on their Window's machine, I suggest using Cygwin - it's Open Source.

Script to display Thomson DSL line statistics

Keywords: DSL modem, line stats, Thomson, SpeedTouch
Depends on RPM(s) - openSUSE: expect, telnet
Download:  get_dsl_modem_1

It's important to document one's DSL modem's line statistics (line stats) when the connection is working well.  In the event an issue crops up (e.g. losing sync), you have a baseline to compare.  More importantly, you can show your ISP the before and after line stats.

This script calls expect to log in to a Thomson DSL modem and fetch the line statistics.  The results are displayed to stdout.  See the script's Configuration section if you're modem is set up in a non-standard way (e.g. not the default user, etc.)

Updates:
  • Fixed bug where $MODEM wasn't being used.