Using lua for configuration gives a lot of flexibility and control: conditional blocks, click handlers in lua, custom formatting in lua, dynamic themes/icons and a lot more. Here is an example of a lua config (it actually works):
-- Returns command's output
local function cmd(c)
local proc = io.popen(c)
local output = proc:read()
proc:close()
return output
end
-- Set icons and theme
config.icons = "material-nf"
config.theme = {
name = "slick",
overrides = {
alternating_tint_bg = "#0C0C0C00",
alternating_tint_fg = "#0C0C0C00",
}
}
-- Simple, unconditional block (`block` function just appends to the `config.block` table)
block {
block = "disk_space",
info_type = "available",
alert_unit = "GB",
alert = 10.0,
warning = 15.0,
format = "$available"
}
-- As an example, add kbd layout block only if more than one layout is available
local layouts_cnt = cmd("swaymsg -t get_inputs | jq '.[].xkb_layout_names | length | select(. > 0)' | head -n1")
if (layouts_cnt ~= "1")
then
block {
block = "sway_kbd",
mappings = {
["English (Workman)"] = "EN",
["Russian"] = "RU"
}
}
end
-- It's possible to schedule functions. In this example "hello" is printed to stderr every second.
add_timer(1000, function()
io.stderr:write("hello")
end)
Using
lua
for configuration gives a lot of flexibility and control: conditional blocks, click handlers inlua
, custom formatting inlua
, dynamic themes/icons and a lot more. Here is an example of alua
config (it actually works):