-- XFCE style autostart system
local awful = require("awful")
local gears = require("gears")
local gfs = gears.filesystem
local menu_utils = require("menubar.utils")
local stdir = "/tmp/.awesome_startup/"
gfs.make_directories(stdir)
awful.spawn.with_line_callback("find "..gfs.get_xdg_config_home().."autostart/ -name *.desktop",{
    stdout = function(line)
        local data = menu_utils.parse_desktop_file(line)
        if (data.RunHook == "0") or (data.RunHook == nil) then
            if not gfs.file_readable(stdir..line:match("[^/]*$")) then
                io.open(stdir..line:match("[^/]*$"),"w"):close()
                awful.spawn(data.Exec)
            end
        end
    end
})
