johnhamelink
3/3/2013 - 2:19 AM

rsync.lua

---------------------------------------------------------------------------
-- @author John Hamelink <john@johnhamelink.com>
-- @copyright 2013 John Hamelink
-- @release v1.0
---------------------------------------------------------------------------

local setmetatable = setmetatable
local os = os
local textbox = require("wibox.widget.textbox")
local capi = { timer = timer }

--- Text clock widget.
-- awful.widget.textclock
local rsync = { mt = {} }

function rsync.new(timeout)
    local timeout = timeout or 20

    local script = io.popen("~/.config/awesome/scripts/rsync.sh")
    local rsync = script:read("*a")

    local box = textbox()

    local timer = capi.timer { timeout = timeout }
    timer:connect_signal("timeout", function() box:set_markup(rsync) end)
    timer:start()
    timer:emit_signal("timeout")

    script:close()
    return box
end

function rsync.mt:__call(...)
    return rsync.new(...)
end

return setmetatable(rsync, rsync.mt)

-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80