2 -- Copyright (c) 2007, Bart Trojanowski <bart@jukie.net>
4 -- Browser integration for wmii.
6 -- This plugin depends on xclip utility.
9 local wmii
= require("wmii")
10 local os
= require("os")
11 local string = require("string")
12 local tostring = tostring
18 -- configuration defaults
20 wmii
.set_conf ("browser", "firefox")
24 wmii
.add_action_handler ("browser", function (act
, args
)
26 if type(args
) == "string" then
27 -- create an quoted string, with quotes in the argument escaped
28 url
= args
:gsub("^%s*",""):gsub("%s*$","")
29 url
= "'" .. url
:gsub("'", "\\'") .. "'"
31 -- TODO: need to escape this
34 local browser
= wmii
.get_conf ("browser") or "x-www-browser"
35 local cmd
= browser
.. " " .. url
.. " &"
36 wmii
.log (" executing: " .. cmd
)
40 wmii
.add_action_handler ("google", function (act
, args
)
42 if type(args
) == "string" then
43 -- create an quoted string, with quotes in the argument escaped
44 search
= args
:gsub("^%s*",""):gsub("%s*$","")
45 search
= search
:gsub("'", "\\'")
47 -- TODO: need to escape this
50 local browser
= wmii
.get_conf ("browser") or "x-www-browser"
51 local cmd
= browser
.. " \"http://google.com/search?q=" .. search
.. "\" &"
52 wmii
.log (" executing: " .. cmd
)