Skip to content
Tags

Howto launch a internet search with a global shortcut in KDE

July 5, 2011
I often find myself high-lightening search terms in a program for which I want to perform an internet search. Usually I would open up a browser, open a new tab and paste in the search term and hit enter; pretty tedious. with a 3 liner bash script this can be automated using one dbus command and the global shortcut feature of KDE. I’m using here google and chromium but it should work for any browser which accepts a url as a command argument.
  1. create a shell script google_search.sh with the following content and save it somewhere in your home directory.
    #!/bin/bash
    searchterm=`qdbus org.kde.klipper /klipper getClipboardHistoryItem 0`
    chromium --new-tab "http://www.google.ca/search?&q=$searchterm"

     

  2. Next create a new global custom shortcut in KDE under Systemsettings->Shortcuts And Gestures->Custom Shortcuts. at the bottom click edit -> new -> Global Shortcut and fill in under:
    Action: browse to your newly created script
    Trigger: choose a shortcut of your liking, Mine is Meta+s
    Screenshot GlobalShortcuts in SystemsettingsMake sure the global shortcut is actually checked, if it’s in a folder the folder has to be checked for it to become available.
    If you now highlight anything in a window and press Meta+s a new tab will launch and perform a search for the highlighted searchterm.
Advertisements

From → KDE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: