Categories
Technology

Dark Themes in Ubuntu

I was getting bored with my old Ubuntu theme, so I thought I will play around a little with dark themes.

So here goes:

Here are the list of things used:

Categories
Technology

Fun with X – hacks in Ubuntu

I have always wanted to have more control over my GUI windows so that I can control them and monitor them via commands. So when I looked around for tools to help me do that I found a couple in Ubuntu that help me do some pretty nifty stuff.

So here are a couple of quick hacks:

  • Monitoring what you do on a daily basis:
    Productivity geeks will love this! This is a script which can help you know what the active window title is and print it into a file. Just cron this script to run once a minute and you will have a pretty good picture of what you do on a daily basis. Want to know how much time you spend on Facebook? Try this script!


    printf "`date "+%D %T"`: " >> active-window-log
    active=`xprop -root | grep -P "^_NET_ACTIVE_WINDOW" | awk '{print $NF}'`
    title=`xwininfo -id $active | grep -P "^xwin"` >> active-window-log

    Try this script for a day and you will be amazed by the insights you get by looking at the output log.

  • Monitoring a terminal for changes: How many times has it so happened that you had a terminal which was running a script and you were waiting for it to complete, but then you didn’t know how long it would take before it printed the next line of output? Wouldn’t it be great if you could monitor it?

    So here is the command that you can use to monitor changes to a specific terminal:

    window_id=`xwininfo | grep "Window id" | sed -e 's/.*Window id: //g' -e 's/ .*//g'`;
    xwd -id "$window_id" > /tmp/initial;
    while true;
    do xwd -id "$window_id" > /tmp/final;
    if [ -z "`diff /tmp/initial /tmp/final`" ];
    then echo "No diff";
    else echo "Windows differ";
    rm /tmp/final /tmp/initial;
    break;
    fi;
    sleep 3;
    done

    When you run this script, your mouse pointer changes to a cross-hair. Just point and click the terminal that you want to monitor and then allow it to continue with its work. As soon as there are changes, it will print “Windows differ”. Now you can as well make it send you a mail or start playing a song!

    The cool thing about this script is, it shows how flexible Unix tooling is. The way the script works is by taking a ‘screenshot’ of the terminal every 3 seconds and comparing it with the original screenshot. If there is a change, then diff outputs something and hence becomes non-zero.

The scripts have been tested in Ubuntu. If you don’t have any of the commands, Ubuntu should prompt you to apt-get install them. Although not tested, it should work in any X based system.

Categories
Technology

The power of Ubuntu – showing dynamic messages in your desktop background!

I worked on this cool hack to dynamically show Twitter messages embedded into the desktop background. The basic idea is to have some dynamic text (which could be fetched from the web) embedded in an SVG image, which is set as the desktop background. The SVG image contains the actual wallpaper that we intend to use.


[ad name=”blog-post-ad-wide”]

Here are the steps:

  1. We first start by creating an SVG template file called wall-tmpl.svg with the following contents and saving it in the Wallpapers directory (let’s say it is ~/Theme/Wallpapers):
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
    <!ENTITY ns_imrep "http://ns.adobe.com/ImageReplacement/1.0/">
    <!ENTITY ns_svg "http://www.w3.org/2000/svg">
    <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
    ]>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1280" height="1024" viewBox="0 0 1280 1024" overflow="visible" enable-backgroun
    d="new 0 0 132.72 127.219" xml:space="preserve">
    <image xlink:href="~/Theme/Wallpapers/-your-favorite-wall-paper-" x="0" y="0" width="1280" height="1024"/>
    <text x="100" y="200" fill="white" font-family="Nimbus Mono L" font-size="14" kerning="2">%text</text>
    </svg>
  2. Next we create a script to fetch the most recent Twitter message and then embedding it in the image. The script is called change-wallpaper and is placed in the bin directory. It has the following:
    text=`python -c "import urllib;print eval(urllib.urlopen('http://search.twitter.com/search.json?q=ubuntu&lang=en').read().replace('false', 'False').replace('true', 'True
    ').replace('null', 'None'))['results'][0]['text'].replace('\!','').replace('/','\/')"`
    cat ~/Theme/Wallpapers/wall-tmpl.svg | sed "s/%text/$text/g" > ~/Theme/Wallpapers/wall.svg
  3. We then add the following entry to crontab to fetch Twitter messages every minute:
    # m h dom mon dow command
    * * * * * ~/bin/change-wallpaper
  4. Run the script once, it will create a file called wall.svg in your Wallpapers directory. Set this as your desktop background and watch the background change every minute!

You could get very creative with this. You could have your calendar reminders embedded directly into your desktop background or you could have dynamically fetched background images with your own random fortune quote. The possibilities are enormous!

Categories
Technology

Getting Reliance (Huawei) USB Data Card to work in Ubuntu 9.04 (Jaunty)

In order to get Reliance USB Data Card to work in Ubuntu, follow these steps:

  1. Make sure wvdial is installed
    sudo apt-get install wvdial
  2. Add the device configuration to your /etc/wvdial.conf

    Replace <phone-number> with your 10 digit Reliance connection number.


    [Dialer Defaults]
    Phone =
    Username =
    Password =
    New PPPD = yes


    [Modem0]
    Modem = /dev/ttyUSB0
    Baud = 115200
    SetVolume = 0
    Dial Command = ATDT
    Init1 = ATZ
    FlowControl = Hardware (CRTSCTS)


    [Dialer cdma]
    Username = <phone-number>
    Password = <phone-number>
    Phone = #777
    Stupid Mode = 1
    Inherits = Modem0

  3. Run wvdial
    sudo wvdial cdma

    You will see some output like this:

    ~$ sudo wvdial cdma
    --> WvDial: Internet dialer version 1.60
    --> Cannot get information for serial port.
    --> Initializing modem.
    --> Sending: ATZ
    ATZ
    OK
    --> Modem initialized.
    --> Sending: ATDT#777
    --> Waiting for carrier.
    ATDT#777
    CONNECT 230400
    --> Carrier detected. Starting PPP immediately.
    --> Starting pppd at Sat Jul 11 22:56:19 2009
    --> Pid of pppd: 4299
    --> Using interface ppp0
    --> pppd: ????[18][18]m X[19]m
    --> pppd: ????[18][18]m X[19]m
    --> pppd: ????[18][18]m X[19]m
    --> pppd: ????[18][18]m X[19]m
    --> local IP address <IP>
    --> pppd: ????[18][18]m X[19]m
    --> remote IP address <IP>
    --> pppd: ????[18][18]m X[19]m
    --> primary DNS address <IP>
    --> pppd: ????[18][18]m X[19]m
    --> secondary DNS address <IP>
    --> pppd: ????[18][18]m X[19]m
    --> pppd: ????[18][18]m X[19]m
    --> pppd: ????[18][18]m X[19]m

That’s it! You must now be able to browse the Internet. In order to disconnect press Ctrl+C.

Categories
Technology

Associating files with URLs on Ubuntu (Gnome) – a quick hack

You just downloaded a file from the Internet, for ex, a PDF, a word document from Google Docs, or a video from TED or a talk from Google Videos. You downloaded this file some days back and now, when you viewed it and wanted to know what the world is talking about it, you don’t remember where you downloaded it from and end up searching for the filename or something related to it in Google.

How many times has this happened to you? How nice would it be if it was possible to associate the file with the URL from where you downloaded it or the page associated with it?

I felt the need for this when I downloaded a lot of TED videos recently and wanted a way to go to the TED page describing the video.

I started searching for the quickest way to do it and I found out a quick way to create context menus in Gnome using Nautilus Actions. So all I had to do was to create 2 commands – one for associating the URL and the other to launch the URL. Did you know it is very simple to create contextual commands in Ubuntu Gnome?

Categories
Technology

Getting Rosegarden to work in Ubuntu (Gnome)

I am one of those many people out there who had trouble in getting Rosegarden to “sing” in Ubuntu under Gnome Window Manager. Finally after trying a lot of permutations and combinations, I got Rosegarden to work. I made this post to share what I did so that others don't have to go through the same trouble I did!

So let's proceed.

Required software

Rosegarden requires some other applications to be installed in your system. So before you fire up Rosegarden ensure that you have the following:

  1. qjackctl
  2. qsynth
  3. rosegarden

If you don't have any of these you could execute this:

$ sudo apt-get install qjackctl qsynth rosegarden fluid-soundfont-gm

Ok, now we have everything we need. Let's proceed to the configuration steps:

Start the Jack server

(Somehow not using sudo gave me problems)

$ sudo qjackctl &

Jack Audio Connection Kit setup

Click on Setup
Here are the settings I used:



Start the Jack server



Start the synthesizer

$ sudo qsynth &

QSynth setup

MIDI Setup



Audio Setup



Soundfonts Setup


Start rosegarden

Ok, it's time to fire up Rosegarden.

$ sudo rosegarden &

Configuring Rosegarden

Go to Settings – Configure Rosegarden.




Ensure that the connections are right in Jack Audio Connection Kit (Connect):




Play one of the sample files and you should hear music!



Troubleshooting

In case your Jack server is not running, you might want to execute this command and then start the Jack server:

$ sudo /sbin/alsa force-reload

Update

One of the readers of this post, Jason Friedman, sent me this information via mail:

I read the information you posted about rosegarden at http://gauthampai.livejournal.com/62383.html and it was _very_ helpful. Thank you for posting it.

I am running Linux love 2.6.31-20-generic #57-Ubuntu SMP and I had to do two additional things to hear the audio:




Categories
Technology

Adventure with Ubuntu, Wubi, yum, libc and the like

Note: This is not for the casual reader. If you are facing any issues with any of the keywords mentioned above, you might want to continue…

So here I was trying to install some packages from a YUM repository on my Ubuntu 8.0.4 system. Why YUM when you have apt-get? Well, let's just say, the situation demanded it.

The installation seemed to be going fine. What I did not realize is that, the installation had innocently relinked my libc files to a new location (actually to an older version of libc). The yum installation failed. Without checking the error, I executed sudo yum install again.

And I got this:

sudo: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by sudo)
sudo: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by /lib/libpam.so.0)

Next I executed ls. Same error! And soon I realized, I was not able to execute most of the commands. The only things running were, things that were already open. I had closed my terminal by then, and was not able to bring it back neither was I able to login in an alternative terminal.

It is extremely difficult to figure out what has gone wrong without a terminal. I tried out various things, but I soon realized that since I don't have sudo access anymore, I won't be able to fix anything in the /lib directory, so no point trying.

The only solution was to reboot in recovery mode and then see if I could relink the libc files. So I popped in the Ubuntu live CD.

Now here is an added twist to the tale. I run Ubuntu on Wubi. So how do I mount my NTFS 'file' which is actually a Linux partition?

With some pointers from my colleague, I realized that it is possible to mount a file as if it were a filesystem. I executed this:

mount /dev/windows/filesystem/containing/wubi/installation /media/disk
mount /media/disk/path/to/wubi/disks/root.disk /media/root -o loop

Guess what! The Wubi file got mounted and I was able to access the files.

After some inspection I realized that the problem was that, while Ubuntu has all the libc files in /lib/tls/i686/cmov, the message indicated that these files should be in /lib/tls.

I did a 'ls' in the /lib/tls directory and found that there are some files of an older version of glibc at this location but the live cd version didn't have any files there. So it was apparent this is what is causing the problem.

I unlinked all the files, and relinked them to the new location and rebooted.

This time although it was able to boot Linux, it did not bring up the UI. I booted once again in recovery mode and ran xfix and continued with the boot.

Things seem to be fine now.

Update: Not everything was fine. Some applications, like Totem threw a SEGFAULT. So I did this:

sudo apt-get install --reinstall libc6

Things seem to be fine now.

Categories
Technology

Want a Linux flavor for human beings?

My first experience with any Linux flavor has been usually bad. But this one wasn't.

I had heard about Ubuntu a long time back but somehow could not use it. The requirement of the Internet for installation was too much to ask.

However, I was interested in trying out a new flavor of Linux and so asked for a CD. I like KDE more than Gnome and so I asked for Kubuntu. The coolest feature that I saw was that there was only one CD, which acted like both a Live CD and an installation CD. Boot the OS and if you like it, click on an icon and it installs as if the OS were an application.

There were no hassles. The live CD booted without any problems. I was even able to access the net. was also able to access the net using a USB modem using the Live CD (imagine doing that without even touching your hard drive!). Both of us were excited.

The installation however gave me some problems. (My success rate of installing Linux in one try, thus, still remains at zero! 🙁 ) I had forgotten that I had mounted a Linux ext3 drive and I was trying to format it during the installation. The install process crashed and asked me to refer to some logs for more info (which I did not). Failing during installing Linux is not a big deal! So I tried again.

This time I tried a slightly different option and I was given a clue that I could be trying to format a partition that is mounted.

That was it. I did not face any problems after that.

If you are like others and wants to use open source software, but are shuddered by the idea of a 'Linux installation' or 'package dependencies', try Ubuntu.

There are more packages than you can imagine. There is something (actually a lot) for everyone. You will find applications that you use in your day to day use or atleast find equivalents.

Overall, I am more than satisfied with Kubuntu. Thanks to all the developers and the people behind this wonderful revolution.

Wanna try it out? You can ask for free CD's by asking for it here.

technorati tags:, , , ,