Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- TO DO:
- - Option to center logo vertically
- - Richard Stallman face logo
- - Brackets
- - IRC option
- - Fancy text option
- - Several information thingy's
- - MPD albums
- - % CPU,GPU usage
- ]]
- --___________________________CONFIG___________________________--
- local useLineName = true
- local useLineKernel = false
- local useLineOS = true
- local useLineMemory = false
- local useLineUptime = false
- local useLineTheme = true
- local useLineRes = true
- local useLineCPU = false
- local useLineGPU = false
- local useLineHDD = false
- local useLineBblean = true --If possible
- --____________________________________________________________--
- function warning()
- print("\nThis version of CMDFetch uses Ansicon.")
- print("For all you loyal CMDFetch users, Ansicon replaces \"colous.exe\"")
- print(" Download Ansicon here:")
- print(" http://adoxa.3eeweb.com/ansicon/")
- print("Alternatively, a Cygwin PTY can be used. We recommend Mintty,")
- print("It comes with Cygwin.\n")
- print("If none of these options work for you, you can try it out with")
- print("the \"-c none\" flag\n")
- print("NOTICE: Windows 8 Users should use Ansicon x86 regardless of")
- print("their architecture")
- return
- end
- local failedAnsiconTest = (io.popen("echo.%ANSICON%","r"):read() == "%ANSICON%")
- local terminal = io.popen("2>nul bash -c \"echo $TERM\""):read()
- if terminal then
- local failedCygwinTest = not (terminal:find("xterm") or terminal:find("rxvt"))
- else
- failedCygwinTest = true
- end
- local canColor = not (failedCygwinTest and failedAnsiconTest)
- local resetColor = "\027[0m"
- local logo = "windows7"
- local black,lightBlack = "\027[0;30m","\027[1;30m"
- local red,lightRed = "\027[0;31m","\027[1;31m"
- local green,lightGreen = "\027[0;32m","\027[1;32m"
- local yellow,lightYellow = "\027[0;33m","\027[1;33m"
- local blue,lightBlue = "\027[0;34m","\027[1;34m"
- local violet,lightViolet = "\027[0;35m","\027[1;35m"
- local cyan,lightCyan = "\027[0;36m","\027[1;36m"
- local white,lightWhite = "\027[0;37m","\027[1;37m"
- local colors = {}
- colors["blue"] = {blue,lightBlue}
- colors["yellow"] = {yellow,lightYellow}
- colors["red"] = {red,lightRed}
- colors["green"] = {green,lightGreen}
- colors["violet"] = {violet,lightViolet}
- colors["cyan"] = {cyan,lightCyan}
- colors["black"] = {black,lightBlack}
- colors["white"] = {white,lightWhite}
- colors["none"] = {}
- local colorNames = {"blue","yellow","red","green","violet","cyan","black","white","none"}
- local bright = false
- local minimal = false
- local dull = false
- local moreThanOneLine = true
- local align = false
- local lefty = false
- local gay = false
- local logos = {
- ["windows7"] = {
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} xxxxxxxxxxxxxxxxxxxxxx ${c3}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c3} xxxxxxxxxxxxxxxxxxxxxx ${c1}xxxxxxxxxxxxxxxxxxxxxx %s",
- "${c1} ${c3} %s",
- ["colors"] = {lightWhite,lightGreen,red,lightYellow}
- },
- ["windows"] = {
- "${c1} ## %s",
- "${c1} ###### %s",
- "${c1} ########## %s",
- "${c1} ############## %s",
- "${c3} ## ${c1}########## ${c2}## %s",
- "${c3} ###### ${c1}###### ${c2}###### %s",
- "${c3} ########## ${c1}## ${c2}########## %s",
- "${c3}############## ${c2}############## %s",
- "${c3} ########## ${c4}## ${c2}########## %s",
- "${c3} ###### ${c4}###### ${c2}###### %s",
- "${c3} ## ${c4}########## ${c2}## %s",
- "${c4} ${c4}############## %s",
- "${c4} ########## %s",
- "${c4} ###### %s",
- "${c4} ## %s",
- ["colors"] = {lightRed,lightGreen,lightCyan,lightYellow}
- },
- ["legacy"] = {
- "${c1} ____ %s",
- "${c1} _/ \\_ ${c2}_ _ %s",
- "${c1}| |${c2}| \\____/ | %s",
- "${c1}| |${c2}| | %s",
- "${c1}| ____ |${c2}| | %s",
- "${c1}|_/${c3}____${c1}\\_|${c2}|_ _| %s",
- "${c3} _/ \\_ ${c4}_${c2}\\____/${c4}_ %s",
- "${c3}| |${c4}| \\____/ | %s",
- "${c3}| |${c4}| | %s",
- "${c3}| ____ |${c4}| | %s",
- "${c3}|_/ \\_|${c4}|_ _| %s",
- "${c4} \\____/ %s",
- ["colors"] = {lightRed,lightGreen,lightCyan,lightYellow}
- },
- ["windows8"] = {
- "${c1} ....:::: %s",
- "${c1} ....:::::::::::: %s",
- "${c1} ....:::: :::::::::::::::: %s",
- "${c1}....:::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}................ ................ %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}:::::::::::::::: :::::::::::::::: %s",
- "${c1}'''':::::::::::: :::::::::::::::: %s",
- "${c1} '''':::: :::::::::::::::: %s",
- "${c1} '''':::::::::::: %s",
- "${c1} '''':::: %s",
- ["colors"] = {lightBlue}
- },
- ["none"] = {
- "%s",
- ["colors"] = {resetColor}
- },
- ["gentoo"] = {
- "${c2} -/oyddmdhs+:. %s",
- "${c2} -o${c1}dNMMMMMMMMNNmhy+${c2}-\` %s",
- "${c2} -y${c1}NMMMMMMMMMMMNNNmmdhy${c2}+- %s",
- "${c2} \`o${c1}mMMMMMMMMMMMMNmdmmmmddhhy${c2}/\` %s",
- "${c2} om${c1}MMMMMMMMMMMN${c2}hhyyyo${c1}hmdddhhhd${c2}o\` %s",
- "${c2}.y${c1}dMMMMMMMMMMd${c2}hs++so/s${c1}mdddhhhhdm${c2}+\` %s",
- "${c2} oy${c1}hdmNMMMMMMMN${c2}dyooy${c1}dmddddhhhhyhN${c2}d. %s",
- "${c2} :o${c1}yhhdNNMMMMMMMNNNmmdddhhhhhyym${c2}Mh %s",
- "${c2} .:${c1}+sydNMMMMMNNNmmmdddhhhhhhmM${c2}my %s",
- "${c2} /m${c1}MMMMMMNNNmmmdddhhhhhmMNh${c2}s: %s",
- "${c2} \`o${c1}NMMMMMMMNNNmmmddddhhdmMNhs${c2}+\` %s",
- "${c2} \`s${c1}NMMMMMMMMNNNmmmdddddmNMmhs${c2}/. %s",
- "${c2} /N${c1}MMMMMMMMNNNNmmmdddmNMNdso${c2}:\` %s",
- "${c2}+M${c1}MMMMMMNNNNNmmmmdmNMNdso${c2}/- %s",
- "${c2}yM${c1}MNNNNNNNmmmmmNNMmhs+/${c2}-\` %s",
- "${c2}/h${c1}MMNNNNNNNNMNdhs++/${c2}-\` %s",
- "${c2}\`/${c1}ohdmmddhys+++/:${c2}.\` %s",
- "${c2} \`-//////:--. %s",
- ["colors"] = {lightWhite,lightViolet}
- },
- ["linux"] = {
- "${c2} ##### %s",
- "${c2} ####### %s",
- "${c2} ##${c1}O${c2}#${c1}O${c2}## %s",
- "${c2} #${c3}#####${c2}# %s",
- "${c2} ##${c1}##${c3}###${c1}##${c2}## %s",
- "${c2} #${c1}##########${c2}## %s",
- "${c2} #${c1}############${c2}## %s",
- "${c2} #${c1}############${c2}### %s",
- "${c3} ##${c2}#${c1}###########${c2}##${c3}# %s",
- "${c3} ######${c2}#${c1}#######${c2}#${c3}###### %s",
- "${c3} #######${c2}#${c1}#####${c2}#${c3}####### %s",
- "${c3} #####${c2}#######${c3}##### %s",
- ["colors"] = {lightWhite,lightBlack,lightYellow}
- },
- ["openbsd"] = {
- " ${c3} _ %s",
- " ${c3}(_) %s",
- "${c1} | . %s",
- "${c1} . |L /| . ${c3} _ %s",
- "${c1} _ . |\\ _| \\--+._/| . ${c3}(_) %s",
- "${c1} / ||\\| Y J ) / |/| ./ %s",
- "${c1} J |)'( | \` F\`.'/ ${c3} _ %s",
- "${c1} -<| F __ .-< ${c3}(_) %s",
- "${c1} | / .-'${c3}. ${c1}\`. /${c3}-. ${c1}L___ %s",
- "${c1} J \\ < ${c3}\\ ${c1} | | ${c5}O${c3}\\${c1}|.-' ${c3} _ %s",
- "${c1} _J \\ .- \\${c3}/ ${c5}O ${c3}| ${c1}| \\ |${c1}F ${c3}(_) %s",
- "${c1} '-F -<_. \\ .-' \`-' L__ %s",
- "${c1}__J _ _. >-' ${c2})${c4}._. ${c1}|-' %s",
- "${c1} \`-|.' /_. ${c4}\\_| ${c1} F %s",
- "${c1} /.- . _.< %s",
- "${c1} /' /.' .' \`\\ %s",
- "${c1} /L /' |/ _.-'-\\ %s",
- "${c1} /'J ___.---'\\| %s",
- "${c1} |\\ .--' V | \`. \` %s",
- "${c1} |/\`. \`-. \`._) %s",
- "${c1} / .-.\\ %s",
- "${c1} \\ ( \`\\ %s",
- "${c1} \`.\\ %s",
- ["colors"] = {lightYellow,yellow,lightCyan,lightRed,lightBlack}
- },
- ["dragonflybsd"] = {
- " ${c1} | %s",
- " ${c1} .-. %s",
- " ${c3} ()${c1}I${c3}() %s",
- " ${c1} \"==.__:-:__.==\" %s",
- " ${c1}\"==.__/~|~\\__.==\" %s",
- " ${c1}\"==._( Y )_.==\" %s",
- " ${c2}.-'~~\"\"~=--...,__${c1}\\/|\\/${c2}__,...--=~\"\"~~'-. %s",
- " ${c2}( ..=${c1}\\=${c1}/${c2}=.. ) %s",
- " ${c2}\`'-. ,.-\"\`;${c1}/=\\${c2} ;\"-.,_ .-'\` %s",
- " ${c2} \`~\"-=-~\` .-~\` ${c1}|=|${c2} \`~-. \`~-=-\"~\` %s",
- " ${c2} .-~\` /${c1}|=|${c2}\\ \`~-. %s",
- " ${c2} .~\` / ${c1}|=|${c2} \\ \`~. %s",
- " ${c2} .-~\` .' ${c1}|=|${c2} \\\`. \`~-. %s",
- " ${c2} (\` _,.-=\"\` ${c1} |=|${c2} \`\"=-.,_ \`) %s",
- " ${c2} \`~\"~\"\` ${c1} |=|${c2} \`\"~\"~\` %s",
- " ${c1} /=\\ %s",
- " ${c1} \\=/ %s",
- " ${c1} ^ %s",
- ["colors"] = {lightRed,lightWhite,lightYellow}
- },
- ["trisquel"] = {
- "${c1} \220\220\220\220\220\220 %s",
- "${c1} \220\219\219\219\219\219\219\219\219\219\220 %s",
- "${c1} \220\220\220\220\220\220 \219\219\219\219\223 \223\219\219\219\219 %s",
- "${c1} \220\219\219\219\219\219\219\219\219\219\219\220 \219\219\219\219\223 \220\220 \223\219\219\219 %s",
- "${c1} \220\219\219\219\223\223 \223\223\219\219\219\219 \219\219\219\220 \220\219 \219\219\219 %s",
- "${c1} \220\219\219\219 \220\220\220 \219\219\219\219\220 \223\219\219\219\219\219\219 \220\219\219\219 %s",
- "${c1} \219\219\219 \219\223\223\219\219\220 \219\219\219\219\219\220 \223\223 \220\219\219\219\219 %s",
- "${c1} \223\219\219\219 \219\219\219 \219\219\219\219\219\219\219\220\220 \220\220\219\219\219\219\219\219 %s",
- "${c1} \223\219\219\219\220 \220\219\219\219 \219\219\219\219\219\219\219\219\219\219\219\219\219${c2}\219\219\219\219\223 %s",
- "${c1} \223\219\219\219\219\219\219\219\219\219 \219\219\219\219\219\219\219${c2}\219\219\219\223\223\223 %s",
- "${c1} \223\223\219\219\219\223\223 \219\219${c2}\219\219\219\219\223\223 %s",
- "${c2} \219\219\219\219\219\219\223 \220\220\220\220 %s",
- "${c2} \219\219\219\219\219\223 \219\219\219\219\219\219\219\219 %s",
- "${c2} \219\219\219\219\219 \219\219\219\223 \223\219\219\219 %s",
- "${c2} \219\219\219\219\220 \219\219\220\220\220 \219\219\219 %s",
- "${c2} \219\219\219\219\219\220 \223\223 \220\219\219 %s",
- "${c2} \219\219\219\219\219\219\220\220\220\219\219\219\219 %s",
- "${c2} \223\223\219\219\219\219\219\223\223 %s",
- ["colors"] = {lightBlue,blue}
- },
- ["debian"] = {
- "${c1} _,met$$$\$$gg. %s",
- "${c1} ,g$$$$$$$$$$$$$$$P. %s",
- "${c1} ,g$$P\"\" \"\"\"Y$$.\". %s",
- "${c1} ,$$P' `$$$. %s",
- "${c1}',$$P ,ggs. `$$b: %s",
- "${c1}`d$$' ,$P\"\' ${c2}.${c1} $$$ %s",
- "${c1} $$P d$\' ${c2},${c1} $$P %s",
- "${c1} $$: $$. ${c2}-${c1} ,d$$' %s",
- "${c1} $$\; Y$b._ _,d\$P' %s",
- "${c1} Y$$. ${c2}`.${c1}`\"Y$$$$P\"' %s",
- "${c1} `$$b ${c2}\"-.__ %s",
- "${c1} `Y$$ %s",
- "${c1} `Y$$. %s",
- "${c1} `$$b. %s",
- "${c1} `Y$$b. %s",
- "${c1} `\"Y$b._ %s",
- "${c1} `\"\"\"\" %s",
- ["colors"] = {lightRed,red}
- },
- ["scientific"] = {
- "${c1} =/;;/- %s",
- "${c1} +: // %s",
- "${c1} /; /; %s",
- "${c1} -X H. %s",
- "${c1} .//;;;:;;-, X= :+ .-;:=;:;#;. %s",
- "${c1} M- ,=;;;#:, ,:#;;:=, ,@ %s",
- "${c1} :# :#.=/++++/=.$= #= %s",
- "${c1} ,#; #/:+/;,,/++:+/ ;+. %s",
- "${c1} ,+/. ,;@+, ,#H;, ,/+, %s",
- "${c1} ;+;;/= @. ${c2}.H${c3}#${c2}#X ${c1}-X :///+; %s",
- "${c1} ;+=;;;.@, ${c3}.X${c2}M${c3}@$. ${c1}=X.//;=#/. %s",
- "${c1} ,;: :@#= =$H: .+#- %s",
- "${c1} ,#= #;-///==///-// =#, %s",
- "${c1} ;+ :#-;;;:;;;;-X- +: %s",
- "${c1} @- .-;;;;M- =M/;;;-. -X %s",
- "${c1} :;;::;;-. #- :+ ,-;;-;:== %s",
- "${c1} ,X H. %s",
- "${c1} ;/ #= %s",
- "${c1} // +; %s",
- "${c1} '////' %s",
- ["colors"] = {lightBlue,lightRed,lightWhite}
- },
- ["arch"] = {
- "${c1} -` %s",
- "${c1} .o+` %s",
- "${c1} `ooo/ %s",
- "${c1} `+oooo: %s",
- "${c1} `+oooooo: %s",
- "${c1} -+oooooo+: %s",
- "${c1} `/:-:++oooo+: %s",
- "${c1} `/++++/+++++++: %s",
- "${c1} `/++++++++++++++: %s",
- "${c1} `/+++o${c2}oooooooo${c1}oooo/` %s",
- "${c2} ${c1}./${c2}ooosssso++osssssso${c1}+` %s",
- "${c2} .oossssso-````/ossssss+` %s",
- "${c2} -osssssso. :ssssssso. %s",
- "${c2} :osssssss/ osssso+++. %s",
- "${c2} /ossssssss/ +ssssooo/- %s",
- "${c2} `/ossssso+/:- -:/+osssso+- %s",
- "${c2} `+sso+:-` `.-/+oso: %s",
- "${c2} `++:. `-/+/ %s",
- "${c2} .` `/ %s",
- ["colors"] = {lightCyan,cyan}
- },
- ["oldarch"] = {
- "${c1} __ %s",
- "${c1} _=(SDGJT=_ %s",
- "${c1} _GTDJHGGFCVS) %s",
- "${c1} ,GTDJGGDTDFBGX0 %s",
- "${c1} JDJDIJHRORVFSBSVL${c2}-=+=,_ %s",
- "${c1} IJFDUFHJNXIXCDXDSV,${c2} \"DEBL %s",
- "${c1} [LKDSDJTDU=OUSCSBFLD.${c2} '?ZWX, %s",
- "${c1} ,LMDSDSWH' `DCBOSI${c2} DRDS], %s",
- "${c1} SDDFDFH' !YEWD,${c2} )HDROD %s",
- "${c1} !KMDOCG &GSU|${c2}\\_GFHRGO\\' %s",
- "${c1} HKLSGP'${c2} __${c1}\\TKM0${c2}\\GHRBV)' %s",
- "${c1} JSNRVW'${c2} __+MNAEC${c1}\\IOI,${c2}\\BN' %s",
- "${c1} HELK['${c2} __,=OFFXCBGHC${c1}\\FD) %s",
- "${c1} ?KGHE ${c2}\\_-#DASDFLSV='${c1} 'EF %s",
- "${c1} 'EHTI !H %s",
- "${c1} `0F' '! %s",
- ["colors"] = {lightWhite,lightBlue}
- }
- }
- function errorString(str)
- if canColor then
- print(lightRed.."Error: "..str)
- print("See --help"..resetColor)
- else
- print("Error: "..str)
- print("See --help")
- end
- end
- function lineFromFile(file,num)
- it=1
- for line in file:lines() do
- if num == it then
- return line
- end
- it = it+1
- end
- end
- local OS = lineFromFile(io.popen("wmic os get caption"),2)
- if OS:find("2012") or OS:find("8") then
- logo = "windows8"
- end
- helpLines = {
- "\nUsage: [-h] [-c color] [-l logo] [-b] [-d] [-o OoMm]",
- "Write an OS logo to the output with OS information.\n",
- " -h, --help Write what you're looking at to the output",
- " -c, --color COLOR Change the color of the logo",
- lightWhite.." red, yellow, green, blue, violet",
- " black, white"..resetColor,
- " -l, --logo LOGO Change the logo",
- lightWhite.." Windows8, Windows7, None, OpenBSD",
- " Linux, Debian, Trisquel, DragonFlyBSD",
- " Windows, Legacy, Arch, Oldarch"..resetColor,
- " -b, --bright Use only bright colors",
- " -d, --dull Use only dull colors",
- " -o, --option OPTIONS Use the following options",
- lightWhite.." M = Minimal",
- " m = Not Minimal",
- " O = Use comma separated lists",
- " o = Use multiple lines"..resetColor,
- " --showWarning Show the Ansicon/Cygwin PTY warning.",
- " -a, --align Align the lines",
- " -L, --lefty Flip the logo and information",
- " -g, --gay Gay-ify the logo a la toilet",
- "\nv.2.1.4",
- "By Hal, Zanthas, tested (and approved) by KittyKatt, other people",
- }
- for i = 1,#arg do
- if arg[i] == "--help" or arg[i] == "-h" then
- for i = 1,#helpLines do
- if canColor then
- print(helpLines[i])
- else
- print(helpLines[i]:gsub("\027%[%d-%;-%d-m",""))
- end
- end
- return
- elseif arg[i] == "--logo" or arg[i] == "-l" then
- if arg[i+1] then
- if logos[string.lower(arg[i+1])] then
- logo = string.lower(arg[i+1])
- else
- errorString("flag for logo is not valid")
- return
- end
- else
- errorString("logo flag requires argument")
- return
- end
- elseif arg[i] == "--color" or arg[i] == "-c" then
- if arg[i+1] then
- if colors[string.lower(arg[i+1])] then
- color = string.lower(arg[i+1])
- else
- errorString("invalid color flag")
- return
- end
- else
- errorString("color flag requires an argument")
- return
- end
- elseif arg[i] == "--bright" or arg[i] == "-b" then
- bright = true
- dull = false
- elseif arg[i] == "--dull" or arg[i] == "-d" then
- bright = false
- dull = true
- elseif arg[i] == "--align" or arg[i] == "-a" then
- align = true
- elseif arg[i] == "--lefty" or arg[i] == "-L" then
- lefty = true
- elseif arg[i] == "--gay" or arg[i] == "-g" then
- gay = true
- elseif arg[i] == "--option" or arg[i] == "-o" then
- local args = arg[i+1]
- if args then
- local ConflictO = (args:find("O") and args:find("o"))
- local ConflictM = (args:find("M") and args:find("m"))
- if ConflictO or ConflictM then
- errorString("option flag has conflicting options")
- return
- else
- if args:find("[^OoMm]") then
- errorString("option flag has invalid options")
- return
- end
- if args:find("o") then
- moreThanOneLine = true
- end
- if args:find("O") then
- moreThanOneLine = false
- end
- if args:find("M") then
- minimal = true
- end
- if args:find("m") then
- minimal = false
- end
- end
- else
- errorString("option flag requires an argument")
- return
- end
- elseif arg[i] == "--showWarning" then
- warning()
- return
- end
- end
- if (not canColor) and ((color and color ~= "none") or (not color)) then
- warning()
- return
- end
- if color then
- if color == "none" then
- for i = 1,#logos[logo]["colors"] do
- logos[logo]["colors"][i] = ""
- end
- else
- for i = 1,#logos[logo]["colors"] do
- if colors[color][i] then
- logos[logo]["colors"][i] = colors[color][i]
- else
- logos[logo]["colors"][i] = colors[color][(i%2)+1]
- end
- end
- end
- end
- local bools = {[true]=1,[false]=2}
- if bright or dull then
- for color = 1,#logos[logo]["colors"] do
- for i = 1,#colorNames do
- if logos[logo]["colors"][color] == colors[colorNames[i]][bools[bright]] then
- logos[logo]["colors"][color] = colors[colorNames[i]][bools[dull]]
- end
- end
- end
- end
- --local name = io.popen("echo.%USERNAME%@%USERDOMAIN%","r"):read()--
- local name = io.popen("echo.%USERNAME%","r"):read()
- local kernelOS = io.popen("echo.%OS%","r"):read()
- local kernel = lineFromFile(io.popen("wmic os get version"),2)
- local ramSize = lineFromFile(io.popen("wmic os get totalvisiblememorysize"),2)
- local ramFree = lineFromFile(io.popen("wmic os get freephysicalmemory"),2)
- local architecture = lineFromFile(io.popen("wmic os get osarchitecture"),2)
- ramUsed = ramSize - ramFree
- ramUsed = math.floor((tonumber(ramUsed)/1024)+.5)
- ramSize = math.floor((tonumber(ramSize)/1024)+.5)
- usedPercentage = ramUsed/ramSize*100
- if canColor then
- if usedPercentage <= 25 then
- memoryColor = white
- elseif usedPercentage <= 50 then
- memoryColor = white
- elseif usedPercentage <= 75 then
- memoryColor = white
- else
- memoryColor = white
- end
- else
- memoryColor = ""
- end
- local lastBootUp = lineFromFile(io.popen("wmic os get lastbootuptime"),2)
- local year,month,day,hour,min,sec=(lastBootUp):match("(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)")
- time1 = os.time({
- year = tonumber(year),
- month = tonumber(month),
- day = tonumber(day),
- hour = tonumber(hour),
- min = tonumber(min),
- sec = tonumber(sec)
- })
- local seconds = os.difftime(os.time(),time1)
- local hours = (seconds-(seconds%3600))/3600
- local remainingSeconds = (seconds-(hours*3600))
- local minutes = (remainingSeconds-(remainingSeconds%60))/60
- local seconds = seconds-(hours*3600+minutes*60)
- local firstColor = logos[logo]["colors"][1]
- local theme
- dir = {
- "HKCU","Software","Microsoft","Windows",
- "CurrentVersion","ThemeManager"
- }
- local stringToMatch1 = "[%w%_]+%s+[%w%_]+%s+([%w%_%-%s%%%p]+)"
- local stringToMatch2 = "([%:%p%w%s%\\]+%\\)([%w%_%-%s%%%p]+)"
- local regKey = "reg query "..table.concat(dir,"\\").." /v DllName"
- local themeFileName = lineFromFile(io.popen("2>nul "..regKey),3)
- if themeFileName == nil then
- --There isn't a visual style found, just use the theme file
- --Often in the case of Windows Classic
- dir[6] = "Themes"
- local regKey = "reg query "..table.concat(dir,"\\").." /v CurrentTheme"
- themeName = lineFromFile(io.popen("2>nul "..regKey),3)
- themeName = themeName:match(stringToMatch1)
- pathToTheme,themeName = themeName:match(stringToMatch2)
- --This is more difficult, currently reads the .theme file, if it is
- --determined that it is Windows Classic, use "Windows Classic",
- --otherwise trim the file extension from the theme file and use that.
- for line in io.popen("type \""..pathToTheme..themeName.."\""):lines() do
- found,result = line:find("ColorStyle")
- if found then
- if line:find("Classic") then
- theme = "Windows Classic"
- else
- theme = themeName:match("([%s%w]+)")
- if theme:lower() == "classic" then
- theme = "Windows Classic"
- end
- end
- end
- end
- else
- local themeFileName = themeFileName:match(stringToMatch1)
- pathToTheme,themeName = themeFileName:match(stringToMatch2)
- theme = themeName:match("([%p%w%s%_%$-]+).msstyle")
- --Trimming the file extension should be fine for this.
- end
- local OS = OS:gsub("[^\032%w%p_]","")
- local kernel = kernel:gsub("[^\032%w%p_]","")
- local architecture = architecture:gsub("[^\032%w%p_]","")
- --Weird issue with trimming spaces and line resets with these,
- --don't know cause. Look into it. Likely an issue with wmic?
- --This seems to fix it.
- while OS:sub(-1) == " " do
- OS = OS:sub(1,OS:len()-1)
- end
- while kernel:sub(-1) == " " do
- kernel = kernel:sub(1,kernel:len()-1)
- end
- while architecture:sub(-1) == " " do
- architecture = architecture:sub(1,architecture:len()-1)
- end
- lines = {}
- if useLineName then
- table.insert(lines,firstColor.."Name: "..resetColor..name..resetColor)
- end
- if useLineKernel then
- table.insert(lines,firstColor.."Kernel: "..resetColor..kernelOS.." "..kernel..resetColor)
- end
- if useLineOS then
- table.insert(lines,firstColor.."OS: "..resetColor.."".."Win7HP 64bit"..resetColor)
- end
- if useLineMemory then
- table.insert(lines,firstColor.."Memory: "..memoryColor..ramUsed..resetColor.."/"..ramSize .. " MB")
- end
- if useLineUptime then
- table.insert(lines,firstColor.."Uptime: "..resetColor..hours.."h "..minutes.."m "..seconds.."s")
- end
- if useLineTheme then
- table.insert(lines,firstColor.."Theme: "..resetColor..theme)
- end --Pretty dirty, clean up later
- local bbLeanTheme
- local tasks = io.popen("tasklist")
- for line in tasks:lines() do
- task = line:match("(%w+)%.exe")
- if task == "blackbox" then
- --Check for bbLean
- local dir = io.popen("2>&1 dir /b C:\\bbLean"):read()
- if not dir:find("File Not Found") then
- bbLeanTheme = "Not Found"
- for line in io.open("C:/bbLean/blackbox.rc","r"):lines() do
- key, val = line:match("([%w%.]+): (.+)")
- if key == "session.styleFile" then
- bbLeanTheme = val:match("[\\/](.+)")
- end
- end
- else
- bbLeanTheme = "Not Found"
- end
- end
- end
- if bbLeanTheme and useLineBblean then
- table.insert(lines,firstColor.."bbLean Theme: "..resetColor..bbLeanTheme)
- end
- local height,heightLines = io.popen("wmic desktopmonitor get screenheight"),{}
- local width,widthLines = io.popen("wmic desktopmonitor get screenwidth"),{}
- local cpu,cpuLines = io.popen("wmic cpu get name"),{}
- local gpu,gpuLines = io.popen("wmic path Win32_VideoController get caption"),{}
- local hdd,hddLines = io.popen("wmic logicaldisk get size"),{}
- local freeHDD,freeHDDLines = io.popen("wmic logicaldisk get freespace"),{}
- local objects = {cpu,gpu,height,width,hdd,freeHDD}
- local objectsLines = {cpuLines,gpuLines,heightLines,widthLines,hddLines,freeHDDLines}
- for i = 1,#objects do
- for line in objects[i]:lines() do
- table.insert(objectsLines[i],line)
- end
- end
- local it = 1
- for i = 1,#heightLines do
- if heightLines[i]:match("%d+") then
- local a = widthLines[i]:match("%d+")
- local b = heightLines[i]:match("%d+")
- if moreThanOneLine then
- if heightLines[i] ~= "ScreenHeight" and heightLines[i]:match("%d+") then
- if i == 2 then
- if useLineRes then
- table.insert(lines,firstColor..string.format("Res: %s%sx%s",resetColor,a,b))
- end
- else
- if useLineRes then
- table.insert(lines,string.format(" %s%sx%s",resetColor,a,b))
- end
- end
- end
- elseif heightLines[i]:match("%d+") then
- if i == 2 then
- res = firstColor..string.format("Res: %s%sx%s",resetColor,a,b)
- else
- res = res..","..string.format("%sx%s",a,b)
- end
- end
- end
- end
- local names = {"CPU: ","GPU: "}
- for x = 1,2 do
- local it = 1
- for i = 1,#objectsLines[x] do
- if objectsLines[x][i]:match("%a+") and it > 1 then
- local object = objectsLines[x][i]:gsub("%(%w%)",""):gsub("%s+"," ")
- if moreThanOneLine then
- if it == 2 then
- if not ((x == 1 and not useLineCPU) or (x == 2 and not useLineGPU))then
- table.insert(lines,firstColor..names[x]..resetColor..object)
- end
- else
- if not ((x == 1 and not useLineCPU) or (x == 2 and not useLineGPU))then
- table.insert(lines," "..resetColor..object)
- end
- end
- else
- if it == 2 then
- line = firstColor..names[x]..resetColor..object
- else
- line = line:match("(.-)%s*$")..","..object:match("(.-)%s*$")
- end
- end
- end
- it = it + 1
- end
- if x == 1 then
- cpuline = line
- else
- gpuline = line
- end
- end
- local it = 1
- local newHDDLines = {}
- for i = 1,#hddLines do
- if hddLines[i]:match("%d+") then
- newHDDLines[it] = hddLines[i]
- it = it + 1
- end
- end
- hddLines = newHDDLines
- local it = 1
- local newFreeHDDLines = {}
- for i = 1,#freeHDDLines do
- if freeHDDLines[i]:match("%d+") then
- newFreeHDDLines[it] = freeHDDLines[i]
- it = it + 1
- end
- end
- freeHDDLines = newFreeHDDLines
- for i = 1,#hddLines do
- if hddLines[i]:match("%d+") and it > 1 then
- local hddUsed = tonumber(hddLines[i])-tonumber(freeHDDLines[i])
- local hddPercent = hddUsed/hddLines[i]*100
- if canColor then
- if hddPercent <= 25 then
- color = lightGreen
- elseif hddPercent <= 50 then
- color = green
- elseif hddPercent <= 75 then
- color = lightYellow
- else
- color = red
- end
- else
- color = ""
- end
- hddLines[i] = math.floor(tonumber(hddLines[i])/1024^3+.5)
- hddUsed = math.floor(hddUsed/1024^3+.5)
- if moreThanOneLine then
- if i == 1 then
- if useLineHDD then
- table.insert(lines,firstColor.."Disk space: "..color..hddUsed..resetColor.."/"..hddLines[i].." GB")
- end
- else
- if useLineHDD then
- table.insert(lines," "..color..hddUsed..resetColor.."/"..hddLines[i].." GB")
- end
- end
- else
- if it == 2 then
- hddline = firstColor.."Disk space: "..color..hddUsed..resetColor.."/"..hddLines[i].." GB"
- else
- hddline = hddline..", "..color..hddUsed..resetColor.."/"..hddLines[i].." GB"
- end
- end
- end
- end
- if not moreThanOneLine then
- if useLineRes then
- table.insert(lines,res..resetColor)
- end
- if useLineCPU then
- table.insert(lines,cpuline..resetColor)
- end
- if useLineGPU then
- table.insert(lines,gpuline..resetColor)
- end
- if useLineHDD then
- table.insert(lines,hddline..resetColor)
- end
- end
- if minimal then
- lines = {
- firstColor.."Name: "..resetColor..name..resetColor,
- firstColor.."OS: "..resetColor..OS..resetColor,
- firstColor.."Uptime: "..resetColor..hours.."h "..minutes.."m "..seconds.."s",
- }
- end
- local min
- if align then
- min = 0
- for i = 1,#lines do
- local line = lines[i]:gsub("\027%[%d-%;-%d-m",""):find(":")
- if line then
- min = math.max(min,line)
- end
- end
- for i = 1,#lines do
- local colon = lines[i]:gsub("\027%[%d-%;-%d-m",""):find(":")
- if colon then
- lines[i] = (" "):rep(min-colon)..lines[i]
- else
- lines[i] = (" "):rep(min+1)..lines[i]:match("%s*(.*)")
- end
- end
- end
- local gaycolors = {lightViolet,lightRed,lightYellow,lightGreen,lightCyan,lightBlue}
- if dull then
- gaycolors = {violet,red,yellow,green,cyan,blue}
- end
- if gay then
- for i = 1,#lines do
- local currentline = lines[i]
- local newline = ""
- stat,info = currentline:match("(.+:)(.+)")
- if stat and info then
- stat = stat:gsub("\027%[%d-%;-%d-m","")
- local it = 6
- for i = 1,#stat do --violet,red,yellow,green,cyan,blue
- if it == #gaycolors then
- it = 1
- else
- it = it + 1
- end
- if not (stat:sub(i,i) == " ") then
- newline = newline .. gaycolors[it] .. stat:sub(i,i)
- else
- newline = newline .. " "
- end
- end
- newline = newline .. resetColor .. info
- lines[i] = newline
- end
- end
- end
- local space = 0
- if lefty then
- for i = 1,#lines do
- line = lines[i]:gsub("\027%[%d-%;-%d-m","")
- space = math.max(space,line:len())
- end
- for i = 1,#lines do
- line = lines[i]:gsub("\027%[%d-%;-%d-m","")
- lines[i] = lines[i] .. (" "):rep(space-line:len())
- end
- end
- for line = 1,#logos[logo] do
- local currentLine = logos[logo][line]
- if not gay then
- for inc = 1,#logos[logo]["colors"] do
- currentLine = currentLine:gsub(("%s{c%s}"):format("%$",inc),logos[logo]["colors"][inc])
- currentLine = currentLine:match("(.-)%s*$")
- end
- else
- currentLine = logos[logo][line]:gsub("%$%{c%d%}",""):sub(0,-3)
- local newline = ""
- local it = 6
- for i = 1,#currentLine do
- if it == #gaycolors then
- it = 1
- else
- it = it + 1
- end
- if not (currentLine:sub(i,i) == " ") then
- newline = newline .. gaycolors[it] .. currentLine:sub(i,i)
- else
- newline = newline .. " "
- end
- end
- currentLine = newline .. "%s"
- end
- if lines[line] then
- if not lefty then
- currentLine = currentLine:format(lines[line])
- else
- currentLine = lines[line] .. currentLine:format("")
- end
- else
- if not lefty then
- currentLine = currentLine:format("")
- else
- currentLine = (" "):rep(space)..currentLine:format("")
- end
- end
- if lefty then
- currentLine = " " .. currentLine:match("(.+)%s")
- end
- if canColor then
- print(currentLine..resetColor)
- else
- local currentLine = currentLine:gsub("\027%[%d-%;-%d-m","")
- print(currentLine)
- end
- end
- --gsub("\027%[%d-%;-%d-m","") removes ansi escape codes for color
- --gsub("%$%{c%d%}","") removes color codes in the logos
- local spaces = (" "):rep(logos[logo][1]:gsub("%$%{c%d%}",""):len()-2) --The -2 is for "%s"
- if #lines > #logos[logo] then
- for i = #lines-(#lines - #logos[logo])+1,#lines do
- if canColor then
- if not lefty then
- print(spaces..lines[i]:match("(.-)%s*$"))
- else
- print(lines[i]:match("(.-)%s*$"))
- end
- else
- if not lefty then
- local currentLine = spaces..lines[i]:gsub("\027%[%d-%;-%d-m","")
- print(currentLine:match("(.-)%s*$"))
- else
- local currentLine = lines[i]:gsub("\027%[%d-%;-%d-m","")
- print(currentLine:match("(.-)%s*$"))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment