[Gllug] Re: tiny dictionary-invoking bash script for KDE

Jonathan Hartley tartley at tartley.com
Fri Jun 18 13:53:31 UTC 2004


And this time with the script:

	Tartley

Jonathan Hartley
tartley at tartley.com
+44 (07903) 729 838


#!/bin/bash
#
# dict-lookup
#
# Look up the currently highlighted word in a dictionary.
# Uses kdict (an optional KDE component, from the package 'kdenetwork3-query')
# if it is installed, otherwise invokes konqueror on dictionary.com.
# Works for text selected from any application running on the KDE desktop.
#
# Assign this to a keyboard shortcut (Eg Alt-D) for maximum utility.
# On KDE3.2.3, you have to add it to the Start menu to do this.
#
# Jonathan Hartley, tartley.com, Jun 2004.
# Inspired by Nick Furness' similar Win32/IE widget of many years ago.

# define a URL used to look up dictionary entries
URL_LOOKUP="http://dictionary.com/search?q="

# get most recent text selection from any KDE desktop application
SELECTION=`dcop klipper klipper getClipboardHistoryItem 0`

# is kdict installed?
if [ -x "`which kdict 2>/dev/null`" ]; then
	# kdict installed - so use it
	kdict $SELECTION
else
	# kdict not installed, use konqueror on dictionary.com
	konqueror $URL_LOOKUP$SELECTION
fi



-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list