Archive

Archive for the ‘Open Source’ Category

Change those command-line colors

March 5th, 2009 No comments

The default BASH colors are bearable but maybe you want something else. Myself, I prefer oranges and reds with a little bit of blue mixed in for good measure. Fortunately, in BASH, it’s easy to customize the colours of your shell.

When starting a terminal, BASH reads the .bashrc file to configure how it will display. The .bashrc file is located in your home directory, so within a terminal go home.

cd

Now, rather than define colors within the .bashrc, I prefer to create another file to hold my color configuration.

If you do

touch .$USER\TerminalTweak

then you’ll get a hidden file in your current (home) directory named .UsernameTerminalTweak (Username will be your username).

Open that up with your favorite text editor (I like to use nano for my editing).

nano .UsernameTerminalTweak

And paste the following into it.

function prompt
{
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local YELLOW="\[\033[0;33m\]"
local RED="\[\033[0;31m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
local BLACK="\[\033[0;30m\]"
export PS1="
${YELLOW}\u${BLACK}@${RED}\h ${YELLOW}\w${YELLOW}
$ "
}
prompt

Save the file and then open up your .bashrc

Paste the following at the end of the file.

if [ -f ~/.bashrc ]; then
        source ~/.UsernameTerminalTweak
fi

Now restart your terminal (close and reopen it).

You’ll end up with something like:

Username@PCName ~
$

If you don’t like my color scheme then change the color code in .UsernameTerminalTweak to whatever you like.

XBMC, from the couch with an IR Remote

February 13th, 2009 3 comments

There’s not a whole lot of coverage on how to get your XBMC working with a remote control. Here’s the short of it. If you’ve followed my guide for installing MCE remote control using LIRC with Ubuntu 8.10, and assuming that worked, then this may very well work for you.

Open up a terminal and start irw. We want to echo the keypresses from the IR remote. Mine does something like this for the Play, Left Arrow and Power buttons (just for example).

USER@PC:~$ irw
000000037ff07be9 00 KEY_PLAY mceusb2
000000037ff07bdf 00 KEY_LEFT mceusb2
000000037ff07bf3 00 KEY_POWER mceusb2

Which means when I press the Play button, XBMC is going to want to know that it should be looking for the “KEY_PLAY” message. Here’s how we do that.

First, back up your XBMC Lircmap.xml file. Mine was found in /usr/share/xbmc/system/

sudo cp /usr/share/xbmc/system/Lircmap.xml /usr/share/xbmc/system/Lircmap.xml.orig

That’s just so you’ve got an original to fall back on if things really mess up. Next, download my Lircmap.xml configuration.

wget http://n3wt0n.com/blog/wp-content/uploads/2009/02/lircmap.xml

Stick the Lircmap.xml file in /usr/share/xbmc/system/

sudo mv lircmap.xml /usr/share/xbmc/system/Lircmap.xml

NOTE: Keep a copy of your configured Lircmap.xml handy. I just turned on XBMC today and found that my remote wasn’t working. My customized Lircmap.xml was overwritten (possibly through an update) so I had to find my configured Lircmap.xml and overwrite the default one again.

irw should show you that your keys map the same way mine did (KEY_PLAY, etc). If they don’t, open up the /usr/share/xbmc/system/Lircmap.xml and replace the KEY_X with whatever irw tells you it is.

Here’s a snippet of what my Lircmap.xml looks like:

<lircmap>
    <remote device="mceusb2">
        <pause>KEY_PAUSE</pause>
        <stop>KEY_STOP</stop>
        <forward>KEY_FORWARD</forward>
        <reverse>KEY_REWIND</reverse>
        <left>KEY_LEFT</left>
         ...
        <zero>KEY_0</zero>
        <mytv>KEY_RED</mytv>
        <mymusic>KEY_GREEN</mymusic>
        <mypictures>KEY_YELLOW</mypictures>
        <myvideo>KEY_BLUE</myvideo>
    </remote>

One thing you may notice, and this is very important, is the <remote device=”mceusb2″> part. Remember irw told me that my Play button echos

000000037ff07be9 00 KEY_PLAY mceusb2

Well, pay attention to that mceusb2 part there. If yours does not say mceusb2 then change <remote device=”mceusb2″> to reflect whatever yours may be (perhaps just mceusb).

And contrary to other tutorials out there, you do not need a Keymap.xml file in your ~/.xbmc/userdata directory for this to work.

Ubuntu, from the couch with an IR Remote.

February 13th, 2009 1 comment

irw is the command to test if your IR Remote is working. I’m using a “Windows Vista Certified” MCE remote. irw becomes available when lirc has been installed, so go ahead and install lirc now if you havent’ already.

sudo apt-get install lirc

superm1 at the Ubuntu forums says:

Start out by installing lirc-modules-source
sudo apt-get install lirc-modules-source

Next grab the lirc_mceusb2.c source file from LIRC CVS.

Drop it in the appropriate directory in /usr/src/lirc-0.8.3/
sudo cp lirc_mceusb2.c /usr/src/lirc-0.8.3/lirc_mceusb2

Now issue these commands:
sudo dkms -m lirc -v 0.8.3 build
sudo dkms -m lirc -v 0.8.3 install

Remove and reload the module
sudo rmmod lirc_mceusb2
sudo modprobe lirc_mceusb2

Restart lirc to try it (assuming that it has been configured for a mceusb2 properly)
sudo /etc/init.d/lirc restart

Now you can give irw a try from the command line. It’ll start listening for button presses from the remote. If you press play and it shows that you pushed the play button (or left arrow, right arrow, stop, pause, etc) and the buttons match then that’s good.

Troubleshooting (like I had to do)

If you do this

sudo dkms -m lirc -v 0.8.3 build

and you get this

Error! This module/version has already been built on: 2.6.24-19-generic
Directory: /var/lib/dkms/lirc/0.8.3/2.6.24-19-generic/x86_64
already exists.  Use the dkms remove function before trying to build again.

Then you’ll have to do what it says and use the dkms remove function like this

sudo dkms remove -m lirc -v 0.8.3 --all

followed by

sudo dkms add -m lirc -v 0.8.3

And then pick up from the build stage again. That should set things straight.

Categories: Open Source Tags: , , , ,

Help! My Logitech Dual Action Gamepad isn’t working!

February 3rd, 2009 No comments

Never fret, there’s an easy way to get this handy-dandy and appropriately priced Logitech Dual Action Gamepad working properly (within Ubuntu 8.10).

The symptom is probably that when configuring the game-pad inside a program (other than jscalibrator) that every button works properly, except for the directional-pad (D-Pad).

The problem is most likely that you followed someone else’s advice and tested that the gamepad works by using jscalibrator. That has got to go.

The gamepad works by simply plugging it in! Get rid of jscalibrator.

sudo apt-get remove jscalibrator

And you may want to

sudo apt-get autoremove

to remove any packages that were needed for jscalibrator but are not needed on your system any longer.

jscalibrator also leaves behind a configuration file in your home directory.

ls -la ~/ | grep joystick

should show a file, .joystick, in your home directory. Delete it.

rm ~/.joystick

Reboot your PC. Don’t just log out or ctrl-alt-Backspace, reboot the machine. When you next use your gamepad it should work (now that jscalibrator is gone).

Idols and Icons

January 12th, 2009 No comments

This is too awesome to pass up. I’m reading this article on Ubuntu and it’s rise to prominence and Mark Shuttleworth is quoted as saying, “Look, I have a very privileged life, right? I am a billionaire, bachelor, ex-cosmonaut. Life couldn’t easily be that much better. Being a Linux geek sort of brings balance to the force.”

When I grow up, I want to be Mark Shuttleworth.

Categories: Open Source Tags: , , ,

Switch to our mobile site