You are not logged in.

#1 2006-04-01 17:40:07

sh__
Member
Registered: 2005-07-19
Posts: 272

Fvwm form for various search engines

I wrote a simple fvwm form + bash script that mimics the quick search functionality of some browsers. That is, you hit a key combo (Win-S by default), type "g something" in the form and it googles for "something" with your favourite browser. So basically this eliminates the need to focus on the location bar of the browser.  smile

Currently supported searches are:
g -> Google
w -> Wikipedia
al -> Official Arch repositories
aur -> AUR
aw -> Arch Wiki
mw -> Merriam-Webster Online Dictionary

Fallback option is Google.

The form and the bash script are quite self-explanatory, so they should be easily extendable. Of course you should change the fonts, colorsets, keybinding, default browser etc to your liking.

Here is the form:

DestroyModuleConfig  FvwmSearchForm: *
*FvwmSearchForm: Colorset 7
*FvwmSearchForm: ItemColorset 7
*FvwmSearchForm: Font "xft:Bitstream Vera Sans:Medium:pixelsize=12"
*FvwmSearchForm: ButtonFont "xft:Bitstream Vera Sans:Medium:pixelsize=12"
*FvwmSearchForm: InputFont "xft:Bitstream Vera Sans:Medium:pixelsize=12"
*FvwmSearchForm: Line expand
*FvwmSearchForm: Input Query 32 ""
*FvwmSearchForm: Button quit "Search" ^M
*FvwmSearchForm: Command Exec $HOME/.fvwm/fvwm-search.sh $(Query)
*FvwmSearchForm: Button quit "Cancel" ^[

Key s           A       4      FvwmForm FvwmSearchForm

Style "FvwmSearchForm" GrabFocus

and the accompanying bash script (save to ~/.fvwm/fvwm-search.sh)

#!/bin/bash

#BROWSER="urxvt -e lynx"
#BROWSER="firefox -new-tab"
BROWSER="opera -newpage"

ORIG_QUERY=`echo "$@" | sed 's/  */+/g'`
SEARCH_ENGINE=$1
shift
QUERY=`echo "$@" | sed 's/  */+/g'`

# Choose the search engine

case $SEARCH_ENGINE in 
     g)
     SEARCH="http://www.google.com/search?q=$QUERY&ie=utf-8&oe=utf-8"
     ;;

     w)
     SEARCH="http://en.wikipedia.org/wiki/Special:Search?search=$QUERY"
     ;;

     al)
     SEARCH="http://archlinux.org/packages.php?s_keyword=$QUERY"
     ;;

     aur)
     SEARCH="http://aur.archlinux.org/packages.php?K=$QUERY"
     ;;

     aw)
     SEARCH="http://wiki.archlinux.org/index.php/Special:Search?search=$QUERY"
     ;;

     mw)
     SEARCH="http://www.m-w.com/dictionary/$QUERY"
     ;;

     *)
     # if all else fails, just google it
     SEARCH="http://www.google.com/search?q=$ORIG_QUERY&ie=utf-8&oe=utf-8"
     ;;
esac

exec $BROWSER $SEARCH

Offline

Board footer

Powered by FluxBB