Howto launch a internet search with a global shortcut in KDE
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.
- 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"
- 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
Make 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.