39 lines
747 B
Lua
39 lines
747 B
Lua
local mdadm = {}
|
|
|
|
mdadm.get = function(callback)
|
|
awful.spawn.easy_async("awk '/^md/ {printf \"%s: \", $1}; /blocks/ {print $NF}' /proc/mdstat",
|
|
function(stdout, stderr, exitreason, exitcode)
|
|
status = string.match(stdout, "%[(.*)%]")
|
|
callback(status)
|
|
|
|
end)
|
|
end
|
|
|
|
|
|
|
|
mdadm.indicator_text = wibox.widget.textbox("??")
|
|
mdadm.indicator_text.valign = "center"
|
|
mdadm.indicator_text.align = "center"
|
|
mdadm.indicator_text.font = "Hack NF 10"
|
|
|
|
|
|
mdadm.update_indicator = function(status)
|
|
mdadm.indicator_text.markup = status
|
|
end
|
|
|
|
-- Update the indicator
|
|
mdadm.update_timer = gears.timer {
|
|
timeout = 2,
|
|
call_now = false,
|
|
autostart = true,
|
|
single_shot = false,
|
|
|
|
callback = function()
|
|
mdadm.get(
|
|
mdadm.update_indicator
|
|
)
|
|
end
|
|
}
|
|
|
|
return mdadm
|