User:Esn89

Add a web search prompt on the top.



Put this snippet of Lua code into your keybindings of your rc.lua. Normally, it would be found at:    /home/your_username/.config/awesome/

awful.key( {modkey, }, "s",       function                awful.prompt.run( {prompt = "Web Search: "}, mypromptbox[mouse.screen].widget, function (...) awful.util.spawn(terminal .. "-e " ..               "awesomesearch " .. ...) end, -- Allows for autocompletion using tab (like your shell) awful.completion.shell, -- Allows cycling through searched history using arrows: awful.util.getdir("cache") .. "/history") end),

Next, create a script called "awesomesearch" with the contents:


 * 1) !/bin/bash

browser="firefox" google="http://www.google.ca/search?q=" reddit="reddit.com/search?q=" ebay="www.ebay.ca/sch/items/" ddg="https://www.duckduckgo.com/?q=" wiki="en.wikipedia.org/wiki/" youtube="https://www.youtube.com/results?search_query="
 * 1) places to search

string=${@} bang=${string:0:1} length=${#string} searchterms=${string:2:length} stformatted=$(echo $searchterms | sed 's/ /+/g') if "$bang" = "g" ; then firefox "${google}$stformatted" elif "$bang" = "r" ; then firefox "${reddit}$stformatted" elif "$bang" = "d" ; then firefox "${ddg}$stformatted" elif "$bang" = "d" ; then firefox "${ebay}$stformatted" elif "$bang" = "w" ; then #wiki search terms are a little different: wikist=$(echo $searchterms | sed 's/ /_/g') firefox "${wiki}$wikist" elif "$bang" = "e" ; then firefox "${ebay}$stformatted" elif "$bang" = "y" ; then firefox "${youtube}$stformatted" else echo Strange format... exiting... fi
 * 1) treats the entire parameter as a string
 * 1) finds out the first letter
 * 1) assigns the rest of the string as search terms
 * 1) stformatted is the search terms with "+" placed in between
 * 2) spaces, because we all know how browsers hate spaces.

Save this, make it an executable by going: chmod +x awesomesearch Then place this in your $PATH. (You can find out by going:  echo $PATH) for me, it is in /usr/local/bin

From here, restart awesome-wm and everytime you press mod4+s, a web search prompt will show up.

To conduct a search, simply type in the first letter which defines the search engine:

g for google d for duckduckgo r for reddit e for ebay w for wikipedia y for youtube

followed by your query.

An example would be:  g how to install arch linux y beethoven's 5th symphony

Files can be grabbed here: https://github.com/esn89/searchPrompt