To keep this short and simple, I hadn’t used my netbook for a couple of days and it turns out I had installed xbindkeys. Probably in a case to get a key working as a shortcut for something, but never getting beyond actually installing it and creating the default config as the program suggests by running xbindkeys –defaults > ~/.xbindkeysrc. This just happens to enable 3 default keybindings, one of which is Ctrl-F (!?) to open an xterm. It also grabs that shortcut, and it no longer does its usual task in the program you’re running.

It also ignores xkb keyboard layouts, so for me using dvorak that means my Ctrl-U shortcut just disappeared, no more delete line of text in terminal, yay!

Fortunately I worked out that my issue was with Ctrl-F and a google search for that and xterm keyboard shortcut lead me to a where some poor sob had also run into the issue, but had worked out that xbindkeys was the culprit.

I’ve filed a wishlist bug report on the Debian BTS, but I doubt they’ll see it as something worth fixing.

 

I have run into a couple of shell scripts that print terminal colours as blocks of colour or text but none have been formatted in a way that showed a terminal colour scheme that well. Recently I have taken up adopting the solarized colour scheme but I’ve been trying to modify it slightly to suit my tastes and have had trouble discerning what colours were what, as some colours are replaced with different shades of grey.

Reading the debian planet I came across Antonio Terceiro’s post on a neat simple shell script to print out all the ANSI colour codes and I really like the formatting, so I want to save it here so I don’t forget.

#!/bin/sh -e
 
for attr in $(seq 0 1); do
  for fg in $(seq 30 37); do
    for bg in $(seq 40 47); do
      echo -n "\033[$attr;${bg};${fg}m$attr;$fg;$bg\033[m " 
    done
    echo
  done
done
 

Occasionally I need to extract a source tarball to a subdirectory without its leading path directory and every time I need it I forget the necessary GNU tar switches, so here is todays lesson in the two tar switches required.

tar --strip-components 1 -xvf package_1.1.tar.bz2 -C package

“–strip-components 1″ will strip off the first (1) folder of the archives path. Replacing 1 with 2 will do the obvious and strip off 2 folders/preceding path components.

“-C package” is nice and simple, it will extract the archive into the folder package. You could be fancy and do “-C ~/source/package” and extract the archive anywhere you fancy.

 

A really simple guide to ripping the audio out of a DVD using transcode to wav or mp3.

http://www.ubuntugeek.com/how-to-rip-dvd-audio-to-mp3-or-ogg.html

 

After a boring moment and coming across a little guide video on youtube that used Windows 7 with the rotating desktop wallpapers, I decided to see if I could make rotating wallpapers work in XFCE. A quick google search later and I came across this simple guide: http://www.linuxjournal.com/content/creating-slide-show-backgrounds-xfce

I only had to tweak the cron job line to stop the command output going to system mail every time it ran, and it all worked as expected.

My crontab line: */5 * * * * /usr/bin/xfdesktop –display=:0.0 –reload >/dev/null 2>&1

Another interesting way that doesn’t use cron is described here:

http://rockhopper.dk/linux/software/xfce/xfce-auto-rotate-wallpaper-without-cron/

 

If you have to install CentOS, or you just want to have a nosey, the best way to install it is using the Netinstall CD.

I followed this little guide: http://www.chrisgountanis.com/technical/45-centos-netinstall.html, and it worked out great.

I chose the raw base system install in the graphical installer. It downloaded about 400-500mb of data, installed the packages and after a quick reboot left me with a console screen in vmware, exactly what I wanted.

The only trick was to make sure I was pointing to the right folder in the mirror’s ftp/http directory.

 


When a member of an irc channel I lurk in talked about signing up to the Palm Developer forum this sparked my curiosity about the Palm Pre Developers Kit. So I had a little nosey around the Palm website to see if they had a Linux version of the SDK, which they do. Palm use virtualbox as the virtual machine which is easy to install as well as providing an Ubuntu package for the Pre image. While packaged for Ubuntu also installs with no trouble on Debian squeeze.

The last required package is novacom, the debug/control server required to control the Pre virtual image and let you install any applications you write for the Pre onto the virtual image. This package unfortunately takes advantage of Ubuntu using the Upstart init system instead of init.d as in Debian so does not install cleanly. One option you could take is to uncompress the package and manually install/run the novacom binaries. I chose however to write a simple replacement startup script for init.d, which hopefully is fully functional, and repackage it following this blog post:

http://binaryunit.blogspot.com/2008/01/dist-upgrade-goes-segmentation-fault.html

The Debian package starts novacomd with the init script exactly as the Palm package does using Upstart but also cleanly stops novacomd and should purge the init.d script when purging the config during package removal.

Grab the package here: palm-novacom_0.3-svn177284-hud9_debian_i386

Edit: This package badly fails Lintain and the packaging guidelines, I will try and clean that up and post a more clean package soon fingers crossed.

Edit: Fixed! Mostly ;)

 

Rxvt is a great terminal. When I needed a light weight terminal that supported unicode on my ye olde laptop, rxvt was the answer.

When combined with the font Terminus it quickly became my terminal of choice on the PC as well, but back to the topic at hand. Using a large monitor resolution leaves alot of unused screen real estate and one of the common action I would do with my terminal windows was to tile them, lining each terminal window up against the edge of the screen, and then dragging them half way.

This quickly becomes rediculous manually adjusting windows each time you boot. I searched for ways of tiling windows in XFCE a number of times but either came across posts about using applications to do the tiling or going the the whole way and using a tiling window manager like awsome.

Fortunately last week while exploring the vast rxvt-unicode documentation, trying to solve another issue I came across the geometry command line option.

My terminal tiling is simply two terminals taking up half the desktop each and I use a seperate shortcut for the tiled windows and a generic window, with XFCE’s window management nicely placing the two terminals side by side.

Here is my tiled rxvt command line options from my terminal shortcut:

rxvt-unicode -bg black -fg white -vb -sl 10000 -fn "xft:Terminus" -geometry 102x62

 

As I have mentioned in other posts the ISP plan I have features a higher cost per GB than their regular pay as you go plan, but gives 75 gigabytes free transfer during the offpeak times of 2am-8am. This generally end up working out really well cost wise for me, but most of the traffic measuring tools measure on a day by day basis. Given my delirious state at the time, my previous little vnstat python script was appalling, and doesn’t even work. So here is the new improved version.

'''
VNStat Onpeak/Offpeak calculator
Author: Nameeater
Url: http://www.codemonkies.net/linux
Use: Calculates the data usage during Onpeak, 8am-2am,
     and Offpeak, 2am-8am, using vnstat.
'''
 
#! /usr/bin/env python
 
import os
import time
 
 
totalrx=0
totaltx=0
onpeakrx=0
onpeaktx=0
offpeakrx=0
offpeaktx=0
current_hour=time.localtime()[3]
hour_data=[]
 
vnstat=os.popen('vnstat --dumpdb')
data=vnstat.read()
 
for lines in data.split('\n'):
    if "h;" in lines:
        hour_data.append(lines)
 
for i in hour_data:
    h=i.split(';')
    if int(h[1]) > current_hour:
        break
    if int(h[1]) not in range(2,8):
        #debug print h[1], h[3], h[4]
        onpeakrx+=int(h[3])
        onpeaktx+=int(h[4])
    elif int(h[1]) in range(2,8):
        offpeakrx+=int(h[3])
        offpeaktx+=int(h[4])
 
print time.ctime()
print "-"*6
print "Offpeak Rx: ",offpeakrx/1024, "MB."
print "Offpeak Tx: ",offpeaktx/1024, "MB."
print "-"*6
print "Onpeak Rx: ",onpeakrx/1024, "MB."
print "Onpeak Tx: ",onpeaktx/1024, "MB."
print "-"*6
print "Total Onpeak: ", (onpeakrx+onpeaktx)/1024, "MB."
print "-"*6
 

You can either check if a variable has been defined through exceptions, such as:

try:
    myVariable
except NameError:
    print "myVariable has not been defined."

Or use the locals() and globals() functions to check if the variable has been defined in the matching scope.

if 'myVariable' in locals():
    print "myVariable has been defined."
 
if 'myVariable' in globals():
   print "myVariable has been defined."

This took a little searching to find, but I found the answer over at stackoverflow:

http://stackoverflow.com/questions/843277/python-checking-variable-existing.

© 2012 Linux Sand Garden Suffusion theme by Sayontan Sinha