function neofetch( is_return ) local M = {} function M.get_os_name() local raw_os_name, raw_arch_name = '', '' if jit and jit.os and jit.arch then raw_os_name = jit.os raw_arch_name = jit.arch else if package.config:sub(1,1) == '\\' then raw_os_name = os.getenv('OS') or '' raw_arch_name = os.getenv('PROCESSOR_ARCHITECTURE') or '' else raw_os_name = io.popen('uname -s','r'):read('*l') or '' raw_arch_name = io.popen('uname -m','r'):read('*l') or '' end end raw_os_name = raw_os_name:lower() raw_arch_name = raw_arch_name:lower() local os_patterns = { ['windows'] = 'Windows', ['linux'] = 'Linux', ['mac'] = 'Mac', ['darwin'] = 'Mac', ['bsd$'] = 'BSD', ['sunos'] = 'Solaris', } local arch_patterns = { ['^x86$'] = 'x86', ['i[%d]86'] = 'x86', ['amd64'] = 'x86_64', ['x86_64'] = 'x86_64', ['x64'] = 'x86_64', ['^arm'] = 'arm', ['aarch64'] = 'arm64', } local os_name, arch_name = 'unknown', 'unknown' for pattern, name in pairs(os_patterns) do if raw_os_name:match(pattern) then os_name = name break end end for pattern, name in pairs(arch_patterns) do if raw_arch_name:match(pattern) then arch_name = name break end end return os_name, arch_name end function M.get_cpu_cores() local cores = "unknown" local handle = io.popen('wmic cpu get NumberOfCores') cores = handle:read("*a") handle:close() return cores:match("%d+") or cores end -- Total and used RAM (with percentage) function M.get_memory_info() local total, free = 0, 0 for line in io.popen('wmic ComputerSystem get TotalPhysicalMemory /Value'):lines() do local v = line:match("TotalPhysicalMemory=(%d+)") if v then total = tonumber(v) end end for line in io.popen('wmic OS get FreePhysicalMemory /Value'):lines() do local v = line:match("FreePhysicalMemory=(%d+)") if v then free = tonumber(v)*1024 end end local used = total - free local percent = total > 0 and math.floor(used / total*100) or 0 return total, used, percent end function M.get_disk_usage() local usage = {} for line in io.popen('wmic logicaldisk get Caption,FreeSpace,Size /format:csv'):lines() do if not line:match("Node") and line:match("%S") then local node, caption, free, size = line:match("([^,]*),([^,]*),([^,]*),([^,]*)") caption = caption or "?" free = tonumber(free) or 0 size = tonumber(size) or 0 local used = size - free local percent = (size > 0) and math.floor( used / size*100 ) or 0 table.insert(usage, string.format("%s %.1f GB used / %.1f GB total (%d%%)", caption, (used / 1024^3), (size / 1024^3), percent)) end end for line in io.popen('df -h --output=source,size,used,avail,pcent,target'):lines() do if not line:match("Filesystem") and line:match("%S") then usage[#usage+1] = line end end return table.concat(usage, "
") end function M.get_hostname() local h = io.popen('hostname'):read("*l") return h or "unknown" end function M.get_info() local tempString = "
Process start: #@process_start@#
Uptime: #@uptime@#
Process Load: #@process_load@#%
Process Memory: #@process_memory@#
Paged Memory: #@paged_memory@#
Current Online: #@curr_online@#

OS: #@os@# #@arch@#
HOST: #@host@#
CPU [#@cpucores@# cores]
#@ram@#

DISK USAGE:
#@diskusage@#
OS CLOCK TIME: #@osclock@#
DATE: #@date@#
LUA: #@luaver@#
" local os_name, arch = M.get_os_name() local total, used, percent = M.get_memory_info() local process_start = get_env("process.start") local uptime = get_env("process.uptime") local process_load = get_env("process.load") local process_memory = get_env("process.memory") local paged_memory = get_env("process.paged_memory") local curr_online = function() local usersCnt = tonumber(get_env("game.user_count")) or 0 if usersCnt == 0 then return "0 players" elseif usersCnt == 1 then return "1 player" else return usersCnt .. " players" end end local outputString = sconv(tempString, "#@process_start@#", process_start, "#@uptime@#", uptime, "#@process_load@#", process_load, "#@process_memory@#", process_memory, "#@paged_memory@#", paged_memory, "#@curr_online@#", ( curr_online() ), "#@os@#", os_name, "#@arch@#", arch, "#@host@#", M.get_hostname(), "#@cpucores@#", M.get_cpu_cores(), "#@ram@#", string.format("RAM: %.1f GB used / %.1f GB total (%d%%)", used/1024^3, total/1024^3, percent), "#@diskusage@#", M.get_disk_usage(), "#@osclock@#", os.clock(), "#@date@#", os.date("%d.%m.%Y"), "#@luaver@#", _VERSION) return outputString end function M.show_info() dlg_general(M.get_info()) end if is_return == nil or is_return == '' or is_return == 0 then return M.show_info() else M.get_info() end end function check_globals(names) for _, name in ipairs(names) do local val = _G[name] if val ~= nil then notice(name .. ": V available (" .. type(val) .. ")") else notice(name .. ": X missing") end end end function globalcheck() check_globals({ "os", "io", "table", "string", "math", "debug", "coroutine", "package", "utf8", "collectgarbage" }) end