aweswt with theme support
This commit is contained in:
parent
23c922db3d
commit
c56bbec1db
72
aweswt.lua
72
aweswt.lua
|
@ -4,9 +4,26 @@
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local dmenu = "dmenu -nf '#888888' -nb '#222222' -sf '#ffffff' -sb '#285577' -p 'switch to application:' -fn 'Terminus 8' -i"
|
-- local functions
|
||||||
|
local get_out, get_input, _switch, assemble_command
|
||||||
|
|
||||||
|
local defaults = {}
|
||||||
|
local settings = {}
|
||||||
|
|
||||||
|
defaults.bg_focus = theme.bg_focus
|
||||||
|
defaults.fg_focus = theme.fg_focus
|
||||||
|
defaults.bg_normal = theme.bg_normal
|
||||||
|
defaults.fg_normal = theme.fg_normal
|
||||||
|
defaults.font = string.gsub(theme.font, " ","-")
|
||||||
|
defaults.menu_cmd = "dmenu -nf %q -nb %q -sf %q -sb %q -p 'Switch to' -fn %q -i"
|
||||||
|
|
||||||
|
local command
|
||||||
|
|
||||||
|
for key, value in pairs(defaults) do
|
||||||
|
settings[key] = value
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local get_out, get_input, _switch
|
|
||||||
|
|
||||||
-- switch with window titles
|
-- switch with window titles
|
||||||
M.switch = function()
|
M.switch = function()
|
||||||
|
@ -18,6 +35,41 @@ M.switch_class = function()
|
||||||
_switch(false)
|
_switch(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- {{{ option setters
|
||||||
|
|
||||||
|
M.set_bg_focus = function (color)
|
||||||
|
settings.bg_focus = color or defaults.bg_focus
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
M.set_fg_focus = function (color)
|
||||||
|
settings.fg_focus = color or defaults.fg_focus
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
M.set_bg_normal = function (color)
|
||||||
|
settings.bg_normal = color or defaults.bg_normal
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
M.set_fg_normal = function (color)
|
||||||
|
settings.fg_normal = color or defaults.fg_normal
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
M.set_font = function (font)
|
||||||
|
settings.font = font or defaults.font
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
M.set_menu_command = function (command)
|
||||||
|
settings.menu_cmd = command or defaults.menu_cmd
|
||||||
|
assemble_command()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ io functions
|
||||||
get_out = function (a)
|
get_out = function (a)
|
||||||
local f = io.popen(a)
|
local f = io.popen(a)
|
||||||
t = {}
|
t = {}
|
||||||
|
@ -28,10 +80,13 @@ get_out = function (a)
|
||||||
end
|
end
|
||||||
|
|
||||||
get_input = function (a)
|
get_input = function (a)
|
||||||
s1 = 'echo "' .. a .. '" | ' .. dmenu
|
s1 = 'echo "' .. a .. '" | ' .. command
|
||||||
return get_out(s1)
|
return get_out(s1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ main worker function
|
||||||
_switch = function(use_name)
|
_switch = function(use_name)
|
||||||
local clients = client.get()
|
local clients = client.get()
|
||||||
|
|
||||||
|
@ -68,5 +123,16 @@ _switch = function(use_name)
|
||||||
client_selected:raise()
|
client_selected:raise()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
assemble_command = function()
|
||||||
|
command = string.format(settings.menu_cmd,
|
||||||
|
settings.fg_normal,
|
||||||
|
settings.bg_normal,
|
||||||
|
settings.fg_focus,
|
||||||
|
settings.bg_focus,
|
||||||
|
settings.font)
|
||||||
|
end
|
||||||
|
|
||||||
|
assemble_command()
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in a new issue