dotfiles/.notion/statusd_shellbar.lua

23 lines
560 B
Lua
Raw Normal View History

2022-12-04 23:38:54 +01:00
function get_shell(cmd)
local handle = io.popen(cmd, 'r')
if not handle then
return "could not open shellbar.sh"
end
local result, error = handle:read('*a')
handle:close()
if not result then
return "(" .. error .. ")" -- chance of interrupted system call
2023-01-01 10:16:54 +01:00
-- if not compiled with SA_RESTART signal
2022-12-04 23:38:54 +01:00
end
return result
end
local timer = statusd.create_timer()
local function update()
2023-01-01 10:16:54 +01:00
statusd.inform("shellbar", get_shell('cbar -1'))
timer:set(1000, update)
2022-12-04 23:38:54 +01:00
end
update()