Author Archive


Pin Cygwin to the Windows 7 Taskbar

The launcher for Cygwin is a BAT file. Unfortunately you can’t pin a BAT file to the Windows 7 taskbar. For me this meant I had to keep Cygwin on my desktop instead of having it in a more preferable spot on the taskbar. Here’s a workaround that will allow you to pin Cygwin to your taskbar:

1. During the Cygwin installation process, install the ‘rxvt’ package. This can also be done after the original installation by relaunching the setup file.

2. After ‘rxvt’ finishes installing, create a new shortcut on your desktop. Enter this for the location of the shortcut:
D:\cygwin\bin\rxvt.exe -sr -sl 2500 -sb -geometry 90x30 -fg lightblue -bg midnightblue -tn rxvt -fn "Lucida Console-14" -e /usr/bin/bash --login -i
*replace D:\cygwin with the location of your cygwin installation.

3. Give the shortcut the name “Cygwin” and pin it to your taskbar.

As an added bonus, here is a nicer Cygwin icon that you can use as the icon for your shortcut. Save the icon file to your workstation. Then right-click your new Cygwin shortcut, choose Properties, click the Shortcut tab, click Change Icon, and navigate to where you saved the ICO file. After that you can re-pin the shortcut to your taskbar to update the icon. You may have to log off and back on to see the change.

Thanks to Bob McCormick for some of this info.

Posted in Windows   |   Comments (0)

Control which application launches when you attach your MP3 player – Ubuntu

So you plug in your iPod, and Rhythmbox automatically starts up. But maybe you want GTKPod to start up, or maybe you don’t want any application to automatically launch when you attach your music player. Here’s how to control this:

Open nautilus (file browser).
Click Edit -> Preferences -> Media tab. Click the button next to “Music Player”.

This is the setting that controls what happens when you attach your MP3 player. You can choose another program from the list, choose a program that is not listed, tell it to ask you each time, or choose “Do Nothing”.

This is a Gnome feature, so it should work on any Linux distribution that is running Gnome (Fedora, Suse, Arch, Debian, etc).

Posted in Ubuntu   |   Comments (0)

Ubuntu – Auto-login and lock screen

I like to set up my Ubuntu workstation to automatically log into my account and then immediately lock the screen. This allows all my processes to start up and also allows me to VNC into the main console session via the Remote Desktop (vino) server. There are a few ways to set this up:

First, set up auto-login:
System > Administration > Login Window > Security tab
Check ‘Enable Automatic Login’ and choose your username. Click ‘Close’.

As for locking the screen after login, you can try adding the following command to System > Preferences > Sessions:
gnome-screensaver-command --lock
or
xdg-screensaver lock

I found that these commands worked for me when logging in and out of the box. However, I found that they did not work for me when I rebooted my workstation. If any of the other commands listed Sessions utilize gnome-keyring, such as ‘mail-notification’, the gnome-keyring password prompt seems to keep the screen from being locked. To work around this, I created a script called ‘lockstartup’. This script does the following:

1. Pauses for 10 seconds (a step I found necessary in order to get the script to work correctly)
2. Locks the screen
3. Pauses for another 10 seconds (again, a step I found necessary)
4. Starts any applications that use gnome-keyring

Here is what my script looks like:

#!/bin/sh
sleep 10
xdg-screensaver lock
sleep 10
mail-notification

After you save the script, make it executable:
$ chmod +x lockstartup

And then add it to System > Preferences > Sessions. If you reboot, you should be automatically logged in and then see the screen lock. Once you unlock the screen you should be presented with the gnome-keyring password prompt.

I am using this on Ubuntu 8.10 Intrepid Ibex. I have not tested this on any other releases.

Posted in Ubuntu   |   Comments (8 )

How to ignore a user in Xchat

Here is the syntax to ignore a user in the Xchat IRC application:
/ignore nick!*@* all

Replace ‘nick’ with the nick of the user you want to ignore.

Posted in Miscellaneous   |   Comments (0)

Fix broken WordPress RSS in GoDaddy Free Hosting Accounts

GoDaddy offers free ad-supported web hosting for any domain you register through them. The hosting is the same as their pay Linux Shared Hosting plans, except that they inject a banner advertisement into the top of every page.

I was able to manually install WordPress onto one of my sites that uses this free hosting, however I found that the WordPress RSS feed was broken. When you go to the default address for a Wordpress RSS feed (http://www.domain.com/feed), the page is addressed by a web browser with a mime type of ‘text/html’, even though it is actually an XML document. This results in the GoDaddy ad banner being injected into the XML document, thus invalidating the XML and breaking the RSS feed. Validators will give error messages like:

XML parsing error: :3:0: xml declaration not at start of external entity
Blank line before XML declaration
XML parsing error: <unknown>:199:7: not well-formed (invalid token)

I came up with a workaround that fixes this, here is a summary:
1. Install a plugin that changes the RSS feed paths
2. Write a script to download and cleanup the broken RSS XML files
3. Set up a cron job to update RSS twice an hour

1. Install a plugin that changes the RSS feed paths
Download and install the Feed Locations plugin. Once you enable it, you can access the settings for it in Admin by clicking Tools > Feed Locations. In the configuration screen, I set my feed locations for each feed type to these values:

RSS .92:  http://www.domain.com/rss/rss.xml
RDF (aka RSS 1.0):  http://www.domain.com/rss/rdf.xml
RSS 2.0:  http://www.domain.com/rss/feed.xml
Atom 0.3:  http://www.domain.com/rss/atom.xml
Comments RSS feed:  http://www.domain.com/rss/comments.xml

2. Write a script to download and cleanup the broken RSS XML files
Here is the script file I use to do the rss downloading and code cleanup. I call it ‘rssfeed.sh’. Modify BLOGADDRESS and FEEDPATH to the correct values for your hosting account:

#!/bin/sh
BLOGADDRESS=http://www.domain.com
FEEDPATH=/home/content/d/o/m/domain/html/rss

# NOTHING BELOW THIS LINE SHOULD NEED MODIFIED
# --------------------------------------------
FEEDFILE=${FEEDPATH}/feed.xml
RSSFILE=${FEEDPATH}/rss.xml
RDFFILE=${FEEDPATH}/rdf.xml
ATOMFILE=${FEEDPATH}/atom.xml
COMMENTSFILE=${FEEDPATH}/comments.xml
UBUNTUFILE=${FEEDPATH}/ubuntu.xml


# Remove existing FEEDFILE if it exists
if [ -f ${FEEDFILE} ];
then
   rm ${FEEDFILE}
fi
# Download broken FEEDFILE
wget -q ${BLOGADDRESS}/feed/ -O ${FEEDFILE}
# Remove blank line from beginning of file that breaks FEEDFILE
tail -n +2 ${FEEDFILE} > ${FEEDFILE}1
# Remove GoDaddy code injection from end of file that break FEEDFILE
head -n -2 ${FEEDFILE}1 > ${FEEDFILE}2
# Delete temp file
rm ${FEEDFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/feed.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${FEEDFILE}2 >${FEEDFILE}
# Delete temp file
rm ${FEEDFILE}2


# Remove existing RSSFILE if it exists
if [ -f ${RSSFILE} ];
then
   rm ${RSSFILE}
fi
# Download broken RSSFILE
wget -q ${BLOGADDRESS}/feed/rss/ -O ${RSSFILE}
# Remove blank line from beginning of file that breaks RSSFILE
tail -n +2 ${RSSFILE} > ${RSSFILE}1
# Remove GoDaddy code injection from end of file that break RSSFILE
head -n -2 ${RSSFILE}1 > ${RSSFILE}
# Delete temp file
rm ${RSSFILE}1


# Remove existing RDFFILE if it exists
if [ -f ${RDFFILE} ];
then
   rm ${RDFFILE}
fi
# Download broken RDFFILE
wget -q ${BLOGADDRESS}/feed/rdf/ -O ${RDFFILE}
# Remove blank line from beginning of file that breaks RDFFILE
tail -n +2 ${RDFFILE} > ${RDFFILE}1
# Remove GoDaddy code injection from end of file that break RDFFILE
head -n -2 ${RDFFILE}1 > ${RDFFILE}
# Delete temp file
rm ${RDFFILE}1


# Remove existing ATOMFILE if it exists
if [ -f ${ATOMFILE} ];
then
   rm ${ATOMFILE}
fi
# Download broken ATOMFILE
wget -q ${BLOGADDRESS}/feed/atom/ -O ${ATOMFILE}
# Remove blank line from beginning of file that breaks ATOMFILE
tail -n +2 ${ATOMFILE} > ${ATOMFILE}1
# Remove GoDaddy code injection from end of file that break ATOMFILE
head -n -2 ${ATOMFILE}1 > ${ATOMFILE}2
# Delete temp file
rm ${ATOMFILE}1
# Update feed url to use new feed.xml address
sed 's/\/feed\/atom\/" \/>/\/rss\/atom.xml" \/>/' ${ATOMFILE}2 >${ATOMFILE}
# Delete temp file
rm ${ATOMFILE}2


# Remove existing COMMENTSFILE if it exists
if [ -f ${COMMENTSFILE} ];
then
   rm ${COMMENTSFILE}
fi
# Download broken COMMENTSFILE
wget -q ${BLOGADDRESS}/comments/feed/ -O ${COMMENTSFILE}
## Remove blank line from beginning of file that breaks COMMENTSFILE
tail -n +2 ${COMMENTSFILE} > ${COMMENTSFILE}1
# Remove GoDaddy code injection from end of file that break COMMENTSFILE
head -n -2 ${COMMENTSFILE}1 > ${COMMENTSFILE}2
# Delete temp file
rm ${COMMENTSFILE}1
# Update feed url to use new comments.xml address
sed 's/\/comments\/feed\/\" rel=\"self\" type=\"application\/rss+xml\" \/>/\/rss\/comments.xml\" rel=\"self\" type=\"application\/rss+xml\" \/>/' ${COMMENTSFILE}2 >${COMMENTSFILE}
# Delete temp file
rm ${COMMENTSFILE}2

In your webspace, create a directory called ’scripts’ and a directory called ‘rss’. Once you’ve created ‘rssfeed.sh’, upload it to the ’scripts’ directory. Make the file executable – you can do this with your FTP client by setting the permissions to 755, or you can do this in the file manager that GoDaddy provides.

3. Set up a cron job to update RSS twice an hour
Log into your GoDaddy hosting control panel:
http://www.godaddy.com
Click Hosting > My Hosting Accounts > Manage Accounts

Click Content > Cron Manager > Create Cron Job

Cron Job Title: Update Feed
Command: Browse to the /scripts/rssfeed.sh file that you created
Frequency: Hourly
Minute: x:00
Click Custom.
Checkmark “Run twice an hour”
Click Save.

Note – my cron job didn’t start working as scheduled right away, it took some time for the job to go into effect and start processing for me.

Once you complete all these steps you should have working RSS that updates every 30 minutes. Your main RSS feed address (RSS 2.0) will be http://www.domain.com/feed/feed.xml. You can test it by clicking the RSS icon that shows up in your Firefox address bar when you visit your blog.

Note – These instructions assume that the address for your blog is the root of your domain (http://www.domain.com/). Replace all instances of ‘domain.com’ with your actual web address. If you blog resides in a different directory, such as http://www.domain.com/blog/, you should adjust all paths accordingly (http://www.domain.com/blog/feed/feed.xml for example).

Posted in Code   |   Comments (16 )

Convert mp3 to swf on Linux

I had an mp3 file that I wanted to convert to an SWF Flash file so that I could share a link to it in a project I was working on. Here’s how I did it:

First, install ffmpeg and swftools
$ sudo apt-get install ffmpeg swftools

Convert the mp3 file to wav format
$ ffmpeg -i in.mp3 out.wav

Convert the wav file to an SWF Flash file
$ wav2swf -o filename.swf out.wav -s 44100 -l 100 -d

Posted in Ubuntu   |   Comments (2 )

Install PulseAudio on Xubuntu 8.10 (XFCE)

Here is how to install and use PulseAudio on Xubuntu 8.10 Intrepid Ibex.

1. Install packages for PulseAudio
$ sudo apt-get install libasound2-plugins pulseaudio pulseaudio-esound-compat pulseaudio-module-gconf pulseaudio-module-hal pulseaudio-module-lirc pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-utils paman padevchooser paprefs pavucontrol pavumeter libao-pulse

2. Configure Alsa
Edit the file /etc/asound.conf as root. Create it if it doesn’t exist. Enter the following in this file and save:

pcm.pulse {
    type pulse
}
ctl.pulse {
    type pulse
}
pcm.!default {
    type pulse
}
ctl.!default {
    type pulse
}

3. Add your user account to the pulse groups:

$ sudo gpasswd -a YOURUSERNAME pulse
$ sudo gpasswd -a YOURUSERNAME pulse-access
$ sudo gpasswd -a YOURUSERNAME pulse-rt

4. Configure PulseAudio
Click Applications > Settings > PulseAudio Preferences
On the Network Access tab, check:
– Enable network access to local sound devices
– Allow other machines on the LAN to discover local sound devices
– Don’t require authentication

On the Multicast/RTP tab, check:
– Enable Multicast/RTP receiver
– Enable Multicast/RTP sender

Configure PulseAudio to run as a daemon and allow users to load modules. Edit the file /etc/default/pulseaudio as root.
Change PULSEAUDIO_SYSTEM_START=0 to 1
Change DISALLOW_MODULE_LOADING=1 to 0

Edit the file /etc/libao.conf as root, create it if it doesn’t exist. Enter the following into that file:
default_driver=pulse

Restart your session or reboot to have changes go into effect.

Sources: Ubuntu Wiki, ivotron on Ubuntu Forums, pulseaudio.org

Posted in Ubuntu   |   Comments (10 )

Remote Desktop (VNC) Access on Xubuntu (XFCE) 8.10

Gnome on Ubuntu comes with an included “Remote Desktop” feature (vino) that allows you to VNC into your existing desktop session (usually on the :0 display). However, XFCE does not have a native VNC package built in. The best option I have found is to use vino, the same VNC app that Gnome uses. Here’s how:

Install vino:
$ sudo apt-get install vino

Configure vino:
$ vino-preferences

Then enter this command in your Autostarted Apps to start vino server:
/usr/lib/vino/vino-server

This works well for me, the only feature I have found that doesn’t work is the “disable wallpaper on remote login” setting.

Posted in Ubuntu   |   Comments (4 )

VirtualBox with USB Support on Ubuntu

There are two versions of Virtual Box:
- OSE (Open Source Edition) which is in the repos
- Closed Source Edition, or Standard, or just plain “Virtual Box”

OSE does not have USB support. There are a few other features from the closed source version that aren’t included in OSE, you can see the list here. So, if you want to have USB support in VirtualBox, you need to install closed source edition and make a change to /etc/fstab. Here are the steps:

1. Remove OSE
$ sudo apt-get autoremove virtualbox-ose

2. Add the VirtualBox repo for Intrepid Ibex. Click System > Administration > Software Sources. Click the ‘Third Party Software’ tab. Click ‘Add’ and enter:
deb http://download.virtualbox.org/virtualbox/debian intrepid non-free

Save the VirtualBox GPG key from here, then import it into Synaptic by clicking the ‘Authentication’ tab and then ‘Import Key File’.

Click the ‘Reload’ button in Synaptic to reload the repositories.

3. Install the latest virtualbox package (as of this writing it is virtualbox-2.2) by selecting it in Synaptic, or running this command from a terminal:
$ sudo apt-get install virtualbox-2.2

4. Add yourself to the vboxusers group:
$ sudo gpasswd -a YOURUSERNAME vboxusers

5. Find the devgid for ‘vboxusers’:
$ grep vboxusers /etc/group

It will return something like:
vboxusers:x:125:username

Add this line to the bottom of /etc/fstab, replace the devgid number with your devgid:
none /proc/bus/usb usbfs devgid=125,devmode=664 0 0

After you reboot you should now have USB support in VirtualBox.

Last tested on Ubuntu 9.04 Jaunty Jackalope.

Posted in Ubuntu   |   Comments (41 )

Change screen resolution from the command line with xrandr

The command xrandr can be used to change the screen resolution from the command line. Execute the xrandr command to see available screen resolutions. The output will look like this:

Screen 0: minimum 320 x 240, current 1440 x 900, maximum 1440 x 900
default connected 1440x900+0+0 0mm x 0mm
   1440x900       50.0*
   1360x768       51.0     52.0
   1152x864       53.0
   1024x768       54.0
   960x600        55.0
   960x540        56.0
   840x525        57.0     58.0
   800x600        59.0     60.0
   800x512        61.0
   720x450        62.0
   700x525        63.0
   680x384        64.0     65.0
   640x512        66.0
   640x480        67.0     68.0
   576x432        69.0
   512x384        70.0
   400x300        71.0
   320x240        72.0

To change the resolution:
xrandr -s 1024x768

Posted in Ubuntu   |   Comments (5 )