20 Oct 2009

Smooth volume change in KDE

Of late, I am annoyed by my ThinkPad laptop's volume controls increasing and decreasing volume in steps of 19 (so practically I get only 5 different volume levels).  Today I decided to write a shell script to control volume, rather using the volume buttons on the laptop.  Since I use KDE, making the script talk to KMix using DCOP would be easy and portable (as in, the script will work on any machine running KDE).

KMix's DCOP interface is documented in its manual.  Here is the shell script in its entirety.  It's also available as a downloadable file to save you some typing.

#!/bin/bash
#
# Adjusts speaker volume in KDE.  Does so by sending DCOP commands to KMix.

set -e

function get_volume {
    dcop kmix Mixer0 masterVolume
}

function set_volume {
    dcop kmix Mixer0 setMasterVolume "$1"
}

if [[ "$1" == "" ]]; then
    get_volume
    exit 0
fi

old_volume=$(get_volume)

operator="$1"
shift

case "$operator" in
+)
    set_volume $(expr $(get_volume) + 5)
    ;;
-)
    set_volume $(expr $(get_volume) - 3)
    ;;
*)
    echo >&2 Unrecognized operator "$operator".  Use + to increase and - to decrease volume.
    exit 1
esac

I have saved this file with the name speaker-volume.  When this script is run without any arguments, it prints the current volume level.  When passed "+" as the argument it increases the volume by a small amount, and decreases it when "-" is passed as the argument.

$ ./speaker-volume
58
$ ./speaker-volume +
$ ./speaker-volume
61
$ ./speaker-volume -
$ ./speaker-volume
57

(You may notice that the increase and decrease in the volume is not accurate; I don't know why it is so.  +5 and -3 work reasonably well on my T60p laptop running Kubuntu Hardy.  You may have to tweak these numbers to suit your computer/taste.)

Tip: To make it easy to adjust volume, you can define global shortcut keys as described in my post about adjusting screen brightness.

30 Sept 2009

Heaven and Hell

After being in Hell[*] for about a week, I ran into Yama.  He asked me how everything was, and I said, "it isn't as bad as I had thought."

"I'm glad to know that," he smiled.

"I wonder how Heaven would be!  It must be awesome to live in there," I said.

Yama chuckled and said, "Will tell you a secret.  It's pretty much the same.  Only it has a different name."

I was surprised to no end by this answer.  I thought for a second and said "Hmm... but I guess people in Heaven would be a hundred times happier than those in Hell."

"That's what even the people in Heaven think.  You know what I think?  Heaven and Hell start at Earth, and they end near their entrances."


[*] I mean Hell in general not the Christian Hell.

I'm over you

That's what I believed
Until this night broke me again.
Each broken piece has one want:
Won't you say that at least once?

29 Sept 2009

Some day



Don't remember how long I've been looking at the road and the parked car.  Some day the tyre trails will extend to the road.  Some day I'll have the motivation to drive.  Some day I'll be at the  other end of this road.  Some day I'll think of the blocks that made me park my car and stare at the road.  Yes, some day... but for now, give me a drink!

Photo taken by Bharat Kumar in Death Valley National Park, California.

20 Sept 2009

Search is a hard problem

Text search is a very hard problem.  Especially when it comes to Web search.  Bing is growing very fast as a web search engine, with more than 10% market share.  I've been using Google Search for years, and I like Google.  Every now and then I compare Bing's results with Google's to see how Bing is catching up with Google.

Recently I am annoyed with Java updates plugging in Carbonite backup software, so I wanted to see what people in general think about it.  I did a Twitter search and got no results at all!



I myself had tweeted about it a few days back, so I knew Twitter Search is broken and I should use a different search engine.  I tried Google and found at least 60 tweets!




Now that I am sure Twitter search is terribly broken, I thought of trying the same query on Bing.  Bing cannot see more than 5 tweets.  But still, it's better than Twitter's own search.



For now, I have set up a custom search engine in my Chrome browser so that I can search from the address bar itself.  This is how I did it:

  1. Click on Chrome's wrench menu and choose Options.
  2. In Basic tab, click on Manage button near the default search engine's name.
  3. Click on Add button.
  4. Type http://google.com/search?q=site:twitter.com+%s for URL.
  5. Enter a name and keyword of your choice.  I entered Search Twitter.com as name and twit as keyword.

With this new search keyword, I can type twit bing google in address bar to search for tweets containing the words bing and google.




(BTW, did you notice there's no link to Advanced Search UI from Bing's home page?)