add files
This commit is contained in:
commit
0cb5859e31
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "gnu++17",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"format": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numbers": "cpp",
|
||||
"ostream": "cpp",
|
||||
"semaphore": "cpp",
|
||||
"span": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"variant": "cpp",
|
||||
"codecvt": "cpp"
|
||||
},
|
||||
"C_Cpp.errorSquiggles": "disabled"
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
#include <filesystem>
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
|
||||
struct utsname unameData;
|
||||
|
||||
std::string trim(const std::string& line) {
|
||||
const char* WhiteSpace = " \t\v\r\n";
|
||||
std::size_t start = line.find_first_not_of(WhiteSpace);
|
||||
std::size_t end = line.find_last_not_of(WhiteSpace);
|
||||
return start == end ? std::string() : line.substr(start, end - start + 1);
|
||||
}
|
||||
|
||||
std::string exec(const char* cmd) {
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!pipe) {
|
||||
throw std::runtime_error("popen() failed!");
|
||||
}
|
||||
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) {
|
||||
result += buffer.data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void fumo(std::string distro, std::string kernel, std::string packages, std::string desktop, double diff) {
|
||||
// getting arch
|
||||
uname(&unameData);
|
||||
std::string arch = unameData.machine;
|
||||
|
||||
//getting cpu info
|
||||
std::string cpuinfo_s, cpu, line, init_name;
|
||||
std::ifstream cpuinfo ("/proc/cpuinfo");
|
||||
if ( cpuinfo.is_open() ) {
|
||||
std::string model = "model name";
|
||||
while ( std::getline(cpuinfo, line) ) {
|
||||
size_t found = line.find(model);
|
||||
if (found != std::string::npos) {
|
||||
cpu = line.substr(found + 13);
|
||||
|
||||
// .erase(cpu.find_last_not_of(" \t") + 1);
|
||||
cpu.erase(0, cpu.find_first_not_of(" \t"));
|
||||
cpu.erase(cpu.find_last_not_of((" \t")) +1);
|
||||
line = "";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cout << "/proc/cpuinfo isnt open!" << std::endl;
|
||||
}
|
||||
|
||||
//getting gpu (please help me)
|
||||
//std::string gpu = exec("lspci | grep -m 1 ' VGA ' | cut -d" " -f 9-")
|
||||
|
||||
//getting init
|
||||
if ( std::filesystem::exists("/etc/systemd/system.conf") ) {
|
||||
init_name = "Systemd";
|
||||
} else if ( std::filesystem::exists("/etc/init.d") ) {
|
||||
init_name = "OpenRC";
|
||||
} else if ( std::filesystem::exists("/etc/runit/1") ) {
|
||||
init_name = "Runit";
|
||||
} else {
|
||||
init_name = "i dunno";
|
||||
}
|
||||
|
||||
//getting meminfo
|
||||
std::ifstream meminfo ("/proc/meminfo");
|
||||
std::string total;
|
||||
std::string available;
|
||||
if ( meminfo.is_open() ) {
|
||||
total = "MemTotal:";
|
||||
available = "MemAvailable:";
|
||||
while ( std::getline(meminfo, line) ) {
|
||||
size_t foundt = line.find(total);
|
||||
size_t founda = line.find(available);
|
||||
if ( foundt != std::string::npos ) {
|
||||
total = line.substr(foundt + total.length());
|
||||
total.erase(0, total.find_first_not_of(" \t"));
|
||||
total.erase(total.find_last_not_of(" \t") + 1);
|
||||
total = total.substr(0, total.size()-3);
|
||||
} else if ( founda != std::string::npos ) {
|
||||
available = line.substr(founda + available.length());
|
||||
available.erase(0, available.find_first_not_of(" \t"));
|
||||
available.erase(available.find_last_not_of(" \t") + 1);
|
||||
available = available.substr(0, available.size()-3);
|
||||
}
|
||||
if ( total != "MemTotal:" && available != "MemAvailable:" ) { break; }
|
||||
}
|
||||
}
|
||||
meminfo.close();
|
||||
int used = std::stoi(total) - std::stoi(available);
|
||||
|
||||
|
||||
printf("⠀⢀⣒⠒⠆⠤⣀⡀⠀\n");
|
||||
printf("⢠⡛⠛⠻⣷⣶⣦⣬⣕⡒⠤⢀⣀⠀\n");
|
||||
printf("⡿⢿⣿⣿⣿⣿⣿⡿⠿⠿⣿⣳⠖⢋⣩⣭⣿⣶⡤⠶⠶⢶⣒⣲⢶⣉⣐⣒⣒⣒⢤⡀⠀\n");
|
||||
printf("⣿⠀⠉⣩⣭⣽⣶⣾⣿⢿⡏⢁⣴⠿⠛⠉⠁⠀⠀⠀⠀⠀⠀⠉⠙⠲⢭⣯⣟⡿⣷⣘⠢⡀\n");
|
||||
printf("⠹⣷⣿⣿⣿⣿⣿⢟⣵⠋⢠⡾⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣿⣾⣦⣾⣢\n");
|
||||
printf("⠀⠹⣿⣿⣿⡿⣳⣿⠃⠀⣼⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⣿⣿⣿⠟\n");
|
||||
printf("⠀⠀⠹⣿⣿⣵⣿⠃⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⡄\n");
|
||||
printf("⠀⠀⠀⠈⠛⣯⡇⠛⣽⣦⣿⠀⠀⠀⠀⢀⠔⠙⣄⠀⠀⠀⠀⠀⠀⣠⠳⡀⠀⠀⠀⠀⢿⡵⡀⠀⠀ Distro:\033[36m %s \033[0m\n", distro.c_str());
|
||||
printf("⠀⠀⠀⠀⣸⣿⣿⣿⠿⢿⠟⠀⠀⠀⢀⡏⠀⠀⠘⡄⠀⠀⠀⠀⢠⠃⠀⠹⡄⠀⠀⠀⠸⣿⣷⡀⠀⠀ Kernel:\033[33m %s \033[0m\n", kernel.c_str());
|
||||
printf("⠀⠀⠀⠸⣿⣿⠟⢹⣥⠀⠀⠀⠀⠀⣸⣀⣀⣤⣀⣀⠈⠳⢤⡀⡇⣀⣠⣄⣸⡆⠀⠀⠀⡏⠀⠀ Packages:\033[34m %s \033[0m\n", packages.c_str());
|
||||
printf("⠀⠀⠀⠀⠁⠁⠀⢸⢟⡄⠀⠀⠀⠀⣿⣾⣿⣿⣿⣿⠁⠀⠈⠙⠙⣯⣿⣿⣿⡇⠀⠀⢠⠃ Desktop:\033[31m %s \033[0m\n", desktop.c_str());
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠇⢨⢞⢆⠀⠀⠀⡿⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⣿⣿⣿⡿⡇⠀⣠⢟⡄ Arch:\033[35m %s \033[0m\n", arch.c_str());
|
||||
printf("⠀⠀⠀⠀⠀⠀⡼⠀⢈⡏⢎⠳⣄⠀⡇⠙⠛⠟⠛⠀⠀⠀⠀⠀⠀⠘⠻⠛⢱⢃⡜⡝⠈⠚⡄ CPU:\033[32m %s \033[0m\n", cpu.c_str());
|
||||
printf("⠀⠀⠀⠀⠀⠘⣅⠁⢸⣋⠈⢣⡈⢷⠇⠀⠀⠀⠀⠀⣄⠀⠀⢀⡄⠀⠀⣠⣼⢯⣴⠇⣀⡀⢸ GPU:\033[33m %s \033[0m\n", trim(exec("lspci | grep -m 1 ' VGA ' | cut -d\" \" -f 9-")).c_str());
|
||||
printf("⠀⠀⠀⠀⠀⠀⠈⠳⡌⠛⣶⣆⣷⣿⣦⣄⣀⠀⠀⠀⠈⠉⠉⢉⣀⣤⡞⢛⣄⡀⢀⡨⢗⡦⠎ Init:\033[31m %s \033[0m\n", init_name.c_str());
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠀⠈⠑⠪⣿⠁⠀⠐⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⠉⠁⢸⠀⠀⠀⠄⠙⡆ Shell:\033[35m %s \033[0m\n", getenv("SHELL"));
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠚⡉⢳⡄⠡⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣏⠁⣠⣧⣤⣄⣀⡀⡰⠁ Mem:\033[36m %i/%imb \033[0m\n", used / 1024, std::stoi(total) / 1024);
|
||||
printf("⠀⠀⠀⠀⠀⢀⠔⠉⠀⠀⠀⠀⢀⣧⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣅⡀\n");
|
||||
printf("⠀⠀⠀⠀⠀⢸⠆⠀⠀⠀⣀⣼⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠟⠋⠁⣠⠖⠒⠒⠛⢿⣆\n");
|
||||
printf("⠀⠀⠀⠀⠀⠀⠑⠤⠴⠞⢋⣵⣿⢿⣿⣿⣿⣿⣿⣿⠗⣀⠀⠀⠀⠀⠀⢰⠇⠀⠀⠀⠀⢀⡼⣶⣤\n");
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠟⢛⣿⠀⠙⠲⠽⠛⠛⠵⠞⠉⠙⠳⢦⣀⣀⡞⠀⠀⠀⠀⡠⠋⠐⠣⠮⡁\n");
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⢠⣎⡀⢀⣾⠇⢀⣠⡶⢶⠞⠋⠉⠉⠒⢄⡀⠉⠈⠉⠀⠀⠀⣠⣾⠀⠀⠀⠀⠀⢸⡀\n");
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠘⣦⡀⠘⢁⡴⢟⣯⣞⢉⠀⠀⠀⠀⠀⠀⢹⠶⠤⠤⡤⢖⣿⡋⢇⠀⠀⠀⠀⠀⢸⠀\n");
|
||||
printf("⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠵⠗⠺⠟⠖⢈⡣⡄⠀⠀⠀⠀⢀⣼⡤⣬⣽⠾⠋⠉⠑⠺⠧⣀⣤⣤⡠⠟⠃\n"); // ignore this V
|
||||
std::cout << "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠷⠶⠦⠶⠞⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ You installed " << (int) diff << " days ago" << '\n';
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include "extra.cpp"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
struct stat fileInfo;
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
namespace fs = std::filesystem;
|
||||
// defining
|
||||
const time_t today = std::time(0);
|
||||
std::string distro, kernel, packages, desktop, osrelease_s, line;
|
||||
time_t birth_date;
|
||||
std::ifstream osrelease ("/etc/os-release");
|
||||
|
||||
// reading /etc/os-release to get distro name, under NAME=
|
||||
if ( osrelease.is_open() ) {
|
||||
std::string name = "NAME=";
|
||||
while ( std::getline(osrelease, line) ) {
|
||||
size_t found = line.find(name);
|
||||
if ( found != std::string::npos ) {
|
||||
distro = line.substr(found + name.length());
|
||||
|
||||
distro.erase(0, distro.find_first_not_of(" \t"));
|
||||
distro.erase(distro.find_last_not_of(" \t") + 1);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cout << "/etc/os-release isnt open!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
osrelease.close();
|
||||
|
||||
// getting kernel version
|
||||
uname(&unameData);
|
||||
kernel = unameData.release;
|
||||
|
||||
// getting packages, only works for emerge from gentoo
|
||||
if (fs::is_directory("/var/db/pkg")) {
|
||||
int count = 0;
|
||||
for (const auto& entry : fs::directory_iterator("/var/db/pkg")) {
|
||||
if (fs::is_directory(entry.path())) {
|
||||
for (const auto& sub_entry : fs::directory_iterator(entry.path())) {
|
||||
if (fs::is_directory(sub_entry.path())) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
packages = std::to_string(count);
|
||||
} else {
|
||||
packages = "unsupported :(";
|
||||
}
|
||||
|
||||
// getting desktop env, if it cant read current desktop
|
||||
// it reads desktop session, if both are null then you
|
||||
// dont have a desktop
|
||||
if ( getenv("XDG_CURRENT_DESKTOP") != NULL ) {
|
||||
desktop = getenv("XDG_CURRENT_DESKTOP");
|
||||
} else if ( getenv("DESKTOP_SESSION") != NULL ) {
|
||||
desktop = getenv("DESKTOP_SESSION");
|
||||
} else {
|
||||
desktop = "i dunno :(";
|
||||
}
|
||||
|
||||
// getting date of linux install (theoretical)
|
||||
// uses metadata of the path / to simulate the
|
||||
// oldest thing, obv doesnt work if you
|
||||
// reformatted root
|
||||
if ( stat("/", &fileInfo) == 0 ) {
|
||||
birth_date = fileInfo.st_ctime;
|
||||
} else {
|
||||
birth_date = 0;
|
||||
}
|
||||
double diff = std::difftime(today, birth_date) / (60 * 60 * 24);
|
||||
|
||||
// printing everything out, idk a better way to do it
|
||||
if (argc >= 2 && strcmp(argv[1], "-f") == 0) {
|
||||
fumo(distro, kernel, packages, desktop, diff);
|
||||
return 0;
|
||||
} else {
|
||||
std::cout << " .--." << '\n';
|
||||
std::cout << " |o_o | Distro: " << "\033[36m" << distro << "\033[0m" << '\n';
|
||||
std::cout << " |:_/ | Kernel: " << "\033[33m" << kernel << "\033[0m" << '\n';
|
||||
std::cout << R"( // \ \ Packages: )" << "\033[34m" << packages << "\033[0m" << '\n';
|
||||
std::cout << " (| | ) Desktop: " << "\033[31m" << desktop << "\033[0m" << '\n';
|
||||
std::cout << R"( /'\_ _/`\ )" << '\n';
|
||||
std::cout << R"( \___)=(___/ You installed )" << (int) diff << " days ago" << '\n';
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue