aweswt fix from https://github.com/funkotron/awesome/blob/master/aweswt.lua
This commit is contained in:
parent
c6b1dbc895
commit
e53d6c6853
96
aweswt.lua
96
aweswt.lua
|
@ -1,50 +1,66 @@
|
||||||
-- aweswt.lua
|
-- aweswt.lua
|
||||||
local io=io
|
-- Application switcher using dmenu
|
||||||
local table=table
|
--
|
||||||
local pairs=pairs
|
local io = io
|
||||||
local awful=awful
|
local table = table
|
||||||
local client=client
|
local pairs = pairs
|
||||||
local string=string
|
local awful = awful
|
||||||
local USE_T=true
|
local client = client
|
||||||
module("aweswt")
|
local string = string
|
||||||
function get_out (a)
|
local USE_NAME = true
|
||||||
local f=io.popen (a)
|
|
||||||
t={}
|
module("aweswt")
|
||||||
|
|
||||||
|
function get_out (a)
|
||||||
|
local f = io.popen(a)
|
||||||
|
t = {}
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
table.insert(t, line )
|
table.insert(t, line)
|
||||||
end
|
end
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
function get_input (a)
|
|
||||||
s1='echo -e "'..a..'"|dmenu -i'
|
|
||||||
return get_out(s1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function switch()
|
function get_input (a)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
end
|
|
||||||
else do
|
if USE_NAME then
|
||||||
tmp=i..':'..c['instance']..'.'..c['class']
|
--app = key .. ':' .. string.sub(client['name'], 1, 20)
|
||||||
end
|
app = client['name']
|
||||||
end
|
else
|
||||||
m1=m1..tmp..'\n'
|
app = key .. ':' .. client['instance'] .. '.' .. client['class']
|
||||||
t2[tmp]=c
|
|
||||||
end
|
|
||||||
local t6=t2[get_input(m1)[1]]
|
|
||||||
if t6 then
|
|
||||||
local ctags = t6:tags()
|
|
||||||
awful.tag.viewonly(ctags[1])
|
|
||||||
client.focus = t6
|
|
||||||
t6:raise()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
table.insert(client_list_table, app)
|
||||||
|
apps[app] = client
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(client_list_table, function(a, b)
|
||||||
|
return string.lower(a) < string.lower(b)
|
||||||
|
end)
|
||||||
|
local client_list = table.concat(client_list_table, "\n")
|
||||||
|
|
||||||
|
local client_selected = apps[get_input(client_list)[1]]
|
||||||
|
if client_selected then
|
||||||
|
local ctags = client_selected:tags()
|
||||||
|
awful.tag.viewonly(ctags[1])
|
||||||
|
client.focus = client_selected
|
||||||
|
client_selected:raise()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue