Subscribe to How-To Geek

Enable Google Search From Shortcut Key in KDE on (k)Ubuntu

KDE has an extremely powerful scripted user interface through the use of the dcop utility. You can control virtually any KDE application by entering dcop commands through shell scripts or from the shell itself. These actions can then be tied to menu items, and even hot keys. KDE can also be installed on Ubuntu through the kubuntu-desktop package.

I had asked my friend Caveman a while back if it was possible to select text in any application and do a Google search via a hotkey. He came back 30 minutes later with a solution, which I’m posting for you here.

First, make sure you have the xsel package installed by running the following command:

sudo apt-get install xsel

Now we’ll create a shell script named gsrch.sh and put it in your home folder.

kwrite ~/gsrch.sh

Enter in the following text. Make sure that there isn’t a line break on the second line (and pardon the funky formatting)

#!/bin/bash

dcop `dcopfind -a ‘konqueror-*’` konqueror-mainwindow#1 newTab “http://www.google.com/search?q=`xsel -p -o`&ie=UTF-8&oe=UTF-8″

Now enable execute permissions on the shell script:

chmod u+x ~/gsrch.sh

Now we are ready to add this to an item to the KDE menu. Run kmenuedit to get to the KDE menu editor, and add a new item wherever you feel like:

You can name the item whatever you want, but you will need to browse to the correct path for the command script on your system. Change the work path to be your home directory, and make sure that the “Enable launch feedback” checkbox is Not checked.

Click on the hotkey button in the bottom right hand corner of this window, and set an appropriate hot key. I used Win+G, but you can set it to anything you’d like:

Now we can test it out by selecting text in any window. For instance, I wanted to figure out what this error message means, so I selected the text, and then hit the Win+G hotkey:

And easy as pie, I’ve got a google search window all ready to go:

 

KDE is just amazing! 

The Geek is the founder of How-To Geek and a geek enthusiast. This article was written on 11/25/06 and tagged with: KDE, Kubuntu, Ubuntu, Ubuntu Tips & Tweaks

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:
Similar Articles Featured Wiki Articles
Latest Software Reviews Quick Linux Tips
Geek Arcade Popular Forum Threads

Comments (5)

  1. adam

    is this possible for ginme as well? with firefox -search?

  2. adam

    i ment ginme = “Gnome”

  3. Matt

    Yes there is a gnome like one that I wrote, look it up here.

    http://ubuntuforums.org/showthread.php?t=844780

  4. AdamD

    That tip is really awesome. Thanks for sharing.
    At first I didn’t know it was working, because Konqueror did not raise to the front automatically.
    When I pulled up Konqueror later — there were all my previous searches.

    I was not able to use the ‘win+g’ sequence as you did. It just mapped the ‘g’ key. oops.
    Instead I used Ctl-Shift-G.

    I also add %22 before and after the search term so it searches as a literal string.
    – AdamD

  5. Matt

    I am glad you like it, I have found it useful. Please share it with others. But I am confused about the %22. Can you submit your code so I can take a look.

    Thanks


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Sponsored Links
Getting Started
About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
Cmd.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.