This commit is contained in:
crater2150 2011-12-01 13:03:54 +01:00
parent c6b1dbc895
commit e53d6c6853

View file

@ -1,12 +1,16 @@
-- aweswt.lua -- aweswt.lua
-- Application switcher using dmenu
--
local io = io local io = io
local table = table local table = table
local pairs = pairs local pairs = pairs
local awful = awful local awful = awful
local client = client local client = client
local string = string local string = string
local USE_T=true local USE_NAME = true
module("aweswt") module("aweswt")
function get_out (a) function get_out (a)
local f = io.popen(a) local f = io.popen(a)
t = {} t = {}
@ -15,36 +19,48 @@
end end
return t return t
end end
function get_input (a) function get_input (a)
s1='echo -e "'..a..'"|dmenu -i' local dmenu = "dmenu -nf '#888888' -nb '#222222' -sf '#ffffff' -sb '#285577' -p 'switch to application:' -fn 'Terminus 8' -i"
s1 = 'echo "' .. a .. '" | ' .. dmenu
return get_out(s1) return get_out(s1)
end end
function switch () function switch ()
local clients = client.get() local clients = client.get()
if table.getn(clients) == 0 then if table.getn(clients) == 0 then
return return
end end
local m1=""
local t2={} local client_list_table = {}
local tmp local apps = {}
for i, c in pairs(clients) do
if USE_T then do for key, client in pairs(clients) do
tmp=i..':'..string.sub(c['name'], 1, 20) local app
if USE_NAME then
--app = key .. ':' .. string.sub(client['name'], 1, 20)
app = client['name']
else
app = key .. ':' .. client['instance'] .. '.' .. client['class']
end end
else do
tmp=i..':'..c['instance']..'.'..c['class'] table.insert(client_list_table, app)
apps[app] = client
end end
end
m1=m1..tmp..'\n' table.sort(client_list_table, function(a, b)
t2[tmp]=c return string.lower(a) < string.lower(b)
end end)
local t6=t2[get_input(m1)[1]] local client_list = table.concat(client_list_table, "\n")
if t6 then
local ctags = t6:tags() local client_selected = apps[get_input(client_list)[1]]
if client_selected then
local ctags = client_selected:tags()
awful.tag.viewonly(ctags[1]) awful.tag.viewonly(ctags[1])
client.focus = t6 client.focus = client_selected
t6:raise() client_selected:raise()
end end
end end