Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 497a800ecb | |||
| 64827aa86d | |||
| f90137b4c0 | |||
| 5bbe703ec1 | |||
| d8bc65e0d6 | |||
| 7abb846a81 | |||
| 58bcb147e4 | |||
| ecf066dcb3 | |||
| e6e5648a2d | |||
| e47dc4f7d8 | |||
| 07aad4b651 | |||
| 69f97442a3 | |||
| 0b07013eeb | |||
| 8dd27b7d36 | |||
| d07b345b79 | |||
| e9f1bd31f1 | |||
| e0d49b76f8 | |||
| 4e3089c84e | |||
| 102968d765 | |||
| 3349a53f53 | |||
| b076c02bd4 | |||
| f3d54a04f8 | |||
| de99f162d0 | |||
| 32ac411e0b | |||
| 01fcee75d1 | |||
| e48d93e9f3 | |||
| 1e368b778c | |||
| 4278643462 |
@@ -0,0 +1,80 @@
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: "Optional tag to release (e.g. v1.1)"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:11
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install build dependencies
|
||||
run: apt-get update && apt-get install -y --no-install-recommends make g++ git tar ca-certificates
|
||||
|
||||
- name: Build
|
||||
run: make clean build
|
||||
|
||||
release:
|
||||
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || (github.event_name == 'workflow_dispatch' && inputs.release_tag != '')
|
||||
runs-on: ubuntu-latest
|
||||
container: debian:11
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Checkout (tag push)
|
||||
uses: actions/checkout@v4
|
||||
if: github.event_name == 'push'
|
||||
|
||||
- name: Checkout (manual tag)
|
||||
uses: actions/checkout@v4
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
with:
|
||||
ref: ${{ inputs.release_tag }}
|
||||
|
||||
- name: Install build dependencies
|
||||
run: apt-get update && apt-get install -y --no-install-recommends make g++ git tar ca-certificates
|
||||
|
||||
- name: Build release tarball
|
||||
env:
|
||||
VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}
|
||||
run: |
|
||||
if make -n release >/dev/null 2>&1; then
|
||||
make release VERSION="$VERSION"
|
||||
else
|
||||
make clean build
|
||||
mkdir -p dist
|
||||
tar -C build -czf "dist/fetchit-${VERSION}-linux-x86_64-gnu.tar.gz" fetchit
|
||||
fi
|
||||
|
||||
- name: Upload workflow artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fetchit-${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}-linux-x86_64-gnu
|
||||
path: dist/*.tar.gz
|
||||
|
||||
- name: Publish GitHub release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name }}
|
||||
files: dist/*.tar.gz
|
||||
overwrite_files: true
|
||||
generate_release_notes: true
|
||||
+1
-64
@@ -1,69 +1,6 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Linker files
|
||||
*.ilk
|
||||
|
||||
# Debugger Files
|
||||
*.pdb
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
*.so.*
|
||||
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# Build directories
|
||||
build/
|
||||
Build/
|
||||
build-*/
|
||||
dist/
|
||||
|
||||
# CMake generated files
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.log
|
||||
*.bak
|
||||
*.swp
|
||||
|
||||
# vcpkg
|
||||
vcpkg_installed/
|
||||
|
||||
# debug information files
|
||||
*.dwo
|
||||
|
||||
# test output & cache
|
||||
Testing/
|
||||
.cache/
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
APP := fetchit
|
||||
SRC := main.cpp
|
||||
BUILD_DIR := build
|
||||
DIST_DIR := dist
|
||||
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= $(PREFIX)/bin
|
||||
DESTDIR ?=
|
||||
|
||||
CXX ?= g++
|
||||
CXXFLAGS ?= -O2 -Wall -Wextra -std=c++17 -pipe
|
||||
LDFLAGS ?= -static-libstdc++ -static-libgcc
|
||||
|
||||
VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null)
|
||||
|
||||
.PHONY: all build run install uninstall clean dist release
|
||||
|
||||
all: build
|
||||
|
||||
build: $(BUILD_DIR)/$(APP)
|
||||
|
||||
$(BUILD_DIR)/$(APP): $(SRC) | $(BUILD_DIR)/.dir
|
||||
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS)
|
||||
|
||||
|
||||
$(BUILD_DIR)/.dir:
|
||||
mkdir -p $(BUILD_DIR)
|
||||
touch $@
|
||||
|
||||
run: build
|
||||
./$(BUILD_DIR)/$(APP)
|
||||
|
||||
install: build
|
||||
install -d "$(DESTDIR)$(BINDIR)"
|
||||
install -m 0755 $(BUILD_DIR)/$(APP) "$(DESTDIR)$(BINDIR)/$(APP)"
|
||||
|
||||
uninstall:
|
||||
rm -f "$(DESTDIR)$(BINDIR)/$(APP)"
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD_DIR)/$(APP)
|
||||
|
||||
dist: build | $(DIST_DIR)/.dir
|
||||
tar -C $(BUILD_DIR) -czf $(DIST_DIR)/$(APP)-$(VERSION)-linux-x86_64-gnu.tar.gz $(APP)
|
||||
|
||||
$(DIST_DIR)/.dir:
|
||||
mkdir -p $(DIST_DIR)
|
||||
touch $@
|
||||
|
||||
release: clean build dist
|
||||
@@ -1,2 +1,127 @@
|
||||
# fetchit
|
||||
Works on my machine
|
||||
|
||||
`fetchit` is a Linux terminal system information viewer written in C++. It's a single-file program (`main.cpp`) that prints a colored distro logo (when available) alongside system and hardware info, similar to neofetch/fastfetch.
|
||||
|
||||
## Features
|
||||
|
||||
- Shows: distro, kernel, uptime, shell, CPU, GPU, RAM, and "OS Date".
|
||||
- Distro detection via `/etc/os-release` (`PRETTY_NAME` for display, `ID` for logo matching).
|
||||
- Colored ASCII distro logos for supported distros.
|
||||
- GPU detection by scanning PCI devices (`/sys/bus/pci/devices/`) for class `0x03*`.
|
||||
- GPU name resolution via `/usr/share/hwdata/pci.ids` (falls back to hex IDs if missing).
|
||||
- Accounts for Unicode character width for better alignment in terminals.
|
||||
|
||||
## Supported Distro Logos
|
||||
|
||||
Logos are matched against `/etc/os-release` `ID`:
|
||||
|
||||
`arch`, `cachyos`, `debian`, `ubuntu`, `fedora`, `manjaro`, `opensuse`, `pop`, `linuxmint`, `endeavouros`, `void`, `alpine`
|
||||
|
||||
## Requirements
|
||||
|
||||
- Linux
|
||||
- A C++17-capable compiler (default: `g++`)
|
||||
- UTF-8 locale + ANSI color support (recommended for icons/colors)
|
||||
- Reads the following files/paths:
|
||||
- `/etc/os-release`
|
||||
- `/etc/hostname`
|
||||
- `/proc/uptime`
|
||||
- `/proc/cpuinfo`
|
||||
- `/proc/meminfo`
|
||||
- `/sys/bus/pci/devices/`
|
||||
- `/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
|
||||
- `/usr/share/hwdata/pci.ids` (optional)
|
||||
|
||||
## Build
|
||||
|
||||
### Using the Makefile (recommended)
|
||||
|
||||
```bash
|
||||
make
|
||||
```
|
||||
|
||||
Binary output: `build/fetchit`
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
make run
|
||||
```
|
||||
|
||||
### Manual build
|
||||
|
||||
```bash
|
||||
g++ -O2 -Wall -Wextra -std=c++17 -pipe -o fetchit main.cpp
|
||||
```
|
||||
|
||||
## Install / Uninstall
|
||||
|
||||
Install:
|
||||
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
Defaults:
|
||||
|
||||
- `PREFIX=/usr/local`
|
||||
- `BINDIR=$(PREFIX)/bin`
|
||||
- Installs to: `/usr/local/bin/fetchit`
|
||||
|
||||
Uninstall:
|
||||
|
||||
```bash
|
||||
sudo make uninstall
|
||||
```
|
||||
|
||||
Packaging-friendly variables:
|
||||
|
||||
- `DESTDIR` (staging root)
|
||||
- `PREFIX`, `BINDIR`
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
make install PREFIX=/usr BINDIR=/usr/bin DESTDIR=/tmp/pkgroot
|
||||
```
|
||||
|
||||
## Distribution Archive
|
||||
|
||||
Create a tar.gz containing the built binary:
|
||||
|
||||
```bash
|
||||
make dist
|
||||
```
|
||||
|
||||
Output: `dist/fetchit-<version>-linux-x86_64-gnu.tar.gz`
|
||||
|
||||
`<version>` is derived from:
|
||||
`git describe --tags --dirty --always` (when available)
|
||||
|
||||
Full release pipeline:
|
||||
|
||||
```bash
|
||||
make release
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- `shell` is taken from `$SHELL` and printed as the basename (e.g. `bash`, not `/usr/bin/bash`).
|
||||
- `OS Date` is computed from `/etc/hostname` file metadata (`ctime`) as an elapsed duration; it may not equal the OS install date.
|
||||
- If `pci.ids` is unavailable, GPU(s) are printed as hex IDs like `0xVVVV:0xDDDD`.
|
||||
- If no distro logo matches, the logo section will be empty and only info lines are shown.
|
||||
|
||||
## Sample Output
|
||||
|
||||
```text
|
||||
--- user@host ---
|
||||
|
||||
/\ distro: Arch Linux
|
||||
/ \ kernel: 7.0.10-arch1-1
|
||||
/ \ uptime: 12 minutes
|
||||
/ \ shell: bash
|
||||
/ ,, \ CPU: ... (N) @ X.XX GHz
|
||||
/ | | \ GPU: ...
|
||||
/_-'' ''-_\ RAM: 15.25 GB
|
||||
OS Date: 6 months 17 days 3 hours 40 minutes
|
||||
```
|
||||
|
||||
@@ -3,20 +3,25 @@
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <unordered_map>
|
||||
#include <cctype>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctime>
|
||||
#include <clocale>
|
||||
#include <cwchar>
|
||||
|
||||
using std::string, std::cout;
|
||||
using std::string, std::cout, std::vector;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
string getUser();
|
||||
string getHost();
|
||||
string getDistro();
|
||||
vector<string> distroArt();
|
||||
string getKernel();
|
||||
string getUptime();
|
||||
string getShell();
|
||||
@@ -25,13 +30,46 @@ string getGPU();
|
||||
string getRAM();
|
||||
string getOsDate();
|
||||
|
||||
enum class Color {
|
||||
Red,
|
||||
RedLight,
|
||||
RedDeep,
|
||||
Green,
|
||||
GreenLight,
|
||||
GreenDeep,
|
||||
Blue,
|
||||
BlueLight,
|
||||
BlueDeep,
|
||||
Yellow,
|
||||
YellowLight,
|
||||
Magenta,
|
||||
Purple,
|
||||
PurpleLight,
|
||||
PurpleDeep,
|
||||
Orange,
|
||||
OrangeLight,
|
||||
OrangeDeep,
|
||||
Cyan,
|
||||
Gray,
|
||||
Dark,
|
||||
Reset
|
||||
};
|
||||
|
||||
string color(Color c);
|
||||
|
||||
struct DistroLogo {
|
||||
string id;
|
||||
Color color;
|
||||
std::array<string, 8> art;
|
||||
};
|
||||
|
||||
struct gpuId {
|
||||
string vendor;
|
||||
string device;
|
||||
};
|
||||
|
||||
std::vector<gpuId> getGpuIds() {
|
||||
std::vector<gpuId> gpus;
|
||||
vector<gpuId> getGpuIds() {
|
||||
vector<gpuId> gpus;
|
||||
std::string pciPath = "/sys/bus/pci/devices/";
|
||||
|
||||
for (const auto& entry : fs::directory_iterator(pciPath)) {
|
||||
@@ -50,23 +88,85 @@ std::vector<gpuId> getGpuIds() {
|
||||
return gpus;
|
||||
}
|
||||
|
||||
int main (int argc, const char *argv[]) {
|
||||
const string colorRED = "\033[1;31m";
|
||||
const string colorGREEN = "\033[1;32m";
|
||||
const string colorBLUE = "\033[1;34m";
|
||||
const string colorYELLOW = "\033[1;33m";
|
||||
const string colorMAGENTA = "\033[1;35m";
|
||||
const string colorRESET = "\033[0m";
|
||||
int main () {
|
||||
std::setlocale(LC_ALL, "");
|
||||
|
||||
cout << "\t\t\t--- " << colorGREEN << getUser() << colorRESET << "@" << colorRED << getHost() << colorRESET << " ---\n";
|
||||
cout << colorGREEN << "\t\t distro:\t" << colorRESET << getDistro() << "\n";
|
||||
cout << colorMAGENTA << "\t\t kernel:\t" << colorRESET << getKernel() << "\n";
|
||||
cout << colorBLUE << "\t\t uptime:\t" << colorRESET << getUptime() << "\n";
|
||||
cout << colorMAGENTA << "\t\t shell:\t" << colorRESET << getShell() << "\n";
|
||||
cout << colorYELLOW <<"\t\t CPU: \t" << colorRESET << getCPU() << "\n";
|
||||
cout << colorYELLOW <<"\t\t GPU: \t" << colorRESET << getGPU() << "\n";
|
||||
cout << colorRED << "\t\t RAM: \t" << colorRESET << getRAM() << "\n";
|
||||
cout << colorBLUE << "\t\t OS Date:\t" << colorRESET << getOsDate() << "\n";
|
||||
auto displayWidth = [&](const string& text) {
|
||||
std::mbstate_t state{};
|
||||
const char* src = text.c_str();
|
||||
size_t len = std::mbsrtowcs(nullptr, &src, 0, &state);
|
||||
if (len == static_cast<size_t>(-1)) {
|
||||
return static_cast<int>(text.size());
|
||||
}
|
||||
std::wstring wide(len, L'\0');
|
||||
state = std::mbstate_t{};
|
||||
src = text.c_str();
|
||||
std::mbsrtowcs(wide.data(), &src, len, &state);
|
||||
|
||||
int width = 0;
|
||||
for (wchar_t ch : wide) {
|
||||
int w = wcwidth(ch);
|
||||
if (w > 0) width += w;
|
||||
}
|
||||
return width;
|
||||
};
|
||||
|
||||
auto formatLine = [&](Color c, const string& label, const string& value) {
|
||||
const size_t labelWidth = 12;
|
||||
const size_t valueGap = 2;
|
||||
string padded = label;
|
||||
int currentWidth = displayWidth(padded);
|
||||
if (currentWidth < static_cast<int>(labelWidth)) {
|
||||
padded += string(labelWidth - currentWidth, ' ');
|
||||
}
|
||||
padded += string(valueGap, ' ');
|
||||
return color(c) + padded + color(Color::Reset) + value;
|
||||
};
|
||||
|
||||
vector<string> infoLines = {
|
||||
formatLine(Color::Green, " distro:", getDistro()),
|
||||
formatLine(Color::Magenta, " kernel:", getKernel()),
|
||||
formatLine(Color::Blue, " uptime:", getUptime()),
|
||||
formatLine(Color::Magenta, " shell:", getShell()),
|
||||
formatLine(Color::Yellow, " CPU:", getCPU()),
|
||||
formatLine(Color::Yellow, " GPU:", getGPU()),
|
||||
formatLine(Color::Red, " RAM:", getRAM()),
|
||||
formatLine(Color::Blue, " OS Date:", getOsDate())
|
||||
};
|
||||
|
||||
vector<string> logoLines = distroArt();
|
||||
size_t logoWidth = 0;
|
||||
for (const auto& line : logoLines) {
|
||||
if (line.size() > logoWidth) logoWidth = line.size();
|
||||
}
|
||||
|
||||
const string gap = " ";
|
||||
cout << string(logoWidth, ' ') << gap
|
||||
<< "--- " << color(Color::Green) << getUser() << color(Color::Reset)
|
||||
<< "@" << color(Color::Red) << getHost() << color(Color::Reset) << " ---\n";
|
||||
cout << "\n";
|
||||
|
||||
size_t totalLines = infoLines.size();
|
||||
if (logoLines.size() > totalLines) totalLines = logoLines.size();
|
||||
|
||||
for (size_t i = 0; i < totalLines; ++i) {
|
||||
if (i < logoLines.size()) {
|
||||
cout << logoLines[i];
|
||||
if (logoLines[i].size() < logoWidth) {
|
||||
cout << string(logoWidth - logoLines[i].size(), ' ');
|
||||
}
|
||||
} else {
|
||||
cout << string(logoWidth, ' ');
|
||||
}
|
||||
|
||||
cout << gap;
|
||||
|
||||
if (i < infoLines.size()) {
|
||||
cout << infoLines[i];
|
||||
}
|
||||
|
||||
cout << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -113,7 +213,7 @@ string getDistro() {
|
||||
if(delimiter != string::npos) {
|
||||
string key = line.substr(0, delimiter);
|
||||
|
||||
if (key == "NAME"){
|
||||
if (key == "PRETTY_NAME"){
|
||||
distroName = line.substr(delimiter + 1);
|
||||
distroName = distroName.substr(1, distroName.length() - 2);
|
||||
}
|
||||
@@ -126,6 +226,247 @@ string getDistro() {
|
||||
else return "";
|
||||
}
|
||||
|
||||
string color(Color c) {
|
||||
switch (c) {
|
||||
case Color::Red:
|
||||
case Color::RedLight:
|
||||
case Color::RedDeep:
|
||||
return "\033[1;31m";
|
||||
case Color::Green:
|
||||
case Color::GreenLight:
|
||||
case Color::GreenDeep:
|
||||
return "\033[1;32m";
|
||||
case Color::Blue:
|
||||
case Color::BlueLight:
|
||||
case Color::BlueDeep:
|
||||
return "\033[1;34m";
|
||||
case Color::Yellow:
|
||||
case Color::YellowLight:
|
||||
case Color::Orange:
|
||||
case Color::OrangeLight:
|
||||
case Color::OrangeDeep:
|
||||
return "\033[1;33m";
|
||||
case Color::Magenta:
|
||||
case Color::Purple:
|
||||
case Color::PurpleLight:
|
||||
case Color::PurpleDeep:
|
||||
return "\033[1;35m";
|
||||
case Color::Cyan:
|
||||
return "\033[1;36m";
|
||||
case Color::Gray:
|
||||
case Color::Dark:
|
||||
return "\033[1;37m";
|
||||
case Color::Reset:
|
||||
return "\033[0m";
|
||||
}
|
||||
|
||||
return "\033[0m";
|
||||
}
|
||||
|
||||
vector<string> distroArt() {
|
||||
std::ifstream readOsRelease("/etc/os-release");
|
||||
|
||||
if(!readOsRelease.is_open()) {
|
||||
std::cerr << "Error: Couldn't read /etc/os-release\n";
|
||||
}
|
||||
|
||||
string distroID;
|
||||
string line;
|
||||
while (std::getline(readOsRelease, line)) {
|
||||
if(line.empty() || line[0] == '#') continue;
|
||||
|
||||
std::size_t delimiter = line.find("=");
|
||||
if(delimiter != string::npos) {
|
||||
string key = line.substr(0, delimiter);
|
||||
|
||||
if (key == "ID"){
|
||||
distroID = line.substr(delimiter + 1);
|
||||
if (distroID[0] == '"' && distroID[distroID.length() - 1] == '"') distroID = distroID.substr(1, distroID.length() - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readOsRelease.close();
|
||||
|
||||
const vector<DistroLogo> logos = {
|
||||
{
|
||||
"arch",
|
||||
Color::Blue,
|
||||
{
|
||||
" /\\ ",
|
||||
" / \\ ",
|
||||
" / \\ ",
|
||||
" / \\ ",
|
||||
" / ,, \\ ",
|
||||
" / | | \\ ",
|
||||
"/_-'' ''-_\\",
|
||||
" "
|
||||
}
|
||||
},
|
||||
{
|
||||
"cachyos",
|
||||
Color::Green,
|
||||
{
|
||||
" /''''''''''''/ ",
|
||||
" /''''''''''''/ ",
|
||||
" /''''''/ ",
|
||||
"/''''''/ ",
|
||||
"\\......\\ ",
|
||||
" \\......\\ ",
|
||||
" \\.............../",
|
||||
" \\............./ "
|
||||
}
|
||||
},
|
||||
{
|
||||
"debian",
|
||||
Color::Red,
|
||||
{
|
||||
" _____ ",
|
||||
" / __ \\",
|
||||
"| / |",
|
||||
"| \\___-",
|
||||
"-_ ",
|
||||
" --_ ",
|
||||
" ",
|
||||
" "
|
||||
}
|
||||
},
|
||||
{
|
||||
"ubuntu",
|
||||
Color::Orange,
|
||||
{
|
||||
" _ ",
|
||||
" ,--(_) ",
|
||||
" _/ ;-._\\ ",
|
||||
"(_)( ) )",
|
||||
" \\ ;-'_/ ",
|
||||
" `--(_) "
|
||||
}
|
||||
},
|
||||
{
|
||||
"fedora",
|
||||
Color::Blue,
|
||||
{
|
||||
" _____ ",
|
||||
" / __)\\ ",
|
||||
" | / \\ \\",
|
||||
" ___| |__/ /",
|
||||
" / (_ _)_/ ",
|
||||
"/ / | | ",
|
||||
"\\ \\__/ | ",
|
||||
" \\(_____/ ",
|
||||
}
|
||||
},
|
||||
{
|
||||
"manjaro",
|
||||
Color::Green,
|
||||
{
|
||||
"||||||||| ||||",
|
||||
"||||||||| ||||",
|
||||
"|||| ||||",
|
||||
"|||| |||| ||||",
|
||||
"|||| |||| ||||",
|
||||
"|||| |||| ||||",
|
||||
"|||| |||| ||||",
|
||||
" "
|
||||
}
|
||||
},
|
||||
{
|
||||
"opensuse",
|
||||
Color::Green,
|
||||
{
|
||||
" _______ ",
|
||||
"__| __ \\ ",
|
||||
" / .\\ \\",
|
||||
" \\__/ |",
|
||||
" _______|",
|
||||
" \\_______",
|
||||
"__________/",
|
||||
" "
|
||||
}
|
||||
},
|
||||
{
|
||||
"pop",
|
||||
Color::Cyan,
|
||||
{
|
||||
"______ ",
|
||||
"\\ _ \\ __",
|
||||
" \\ \\ \\ \\ / /",
|
||||
" \\ \\_\\ \\ / / ",
|
||||
" \\ ___\\ /_/ ",
|
||||
" \\ \\ _ ",
|
||||
" __\\_\\__(_)_ ",
|
||||
" (___________)` "
|
||||
}
|
||||
},
|
||||
{
|
||||
"linuxmint",
|
||||
Color::Green,
|
||||
{
|
||||
" __________ ",
|
||||
"|_ \\",
|
||||
" | | _____ |",
|
||||
" | | | | | |",
|
||||
" | | | | | |",
|
||||
" | \\_____/ |",
|
||||
" \\_________/",
|
||||
}
|
||||
},
|
||||
{
|
||||
"endeavouros",
|
||||
Color::Purple,
|
||||
{
|
||||
" /o. ",
|
||||
" /sssso- ",
|
||||
" /ossssssso: ",
|
||||
" /ssssssssssso+ ",
|
||||
" /ssssssssssssssso+",
|
||||
"//osssssssssssssso+-",
|
||||
" `+++++++++++++++-` "
|
||||
}
|
||||
},
|
||||
{
|
||||
"void",
|
||||
Color::Green,
|
||||
{
|
||||
" ____ ",
|
||||
" 'pfPfp.% ",
|
||||
"// _._ \\\\",
|
||||
"UU |===| UU",
|
||||
"\\\\ ^~^ //",
|
||||
" `0PpppP' ",
|
||||
" ````` "
|
||||
}
|
||||
},
|
||||
{
|
||||
"alpine",
|
||||
Color::Blue,
|
||||
{
|
||||
" /\\ /\\ ",
|
||||
" // \\ \\ ",
|
||||
" // \\ \\ ",
|
||||
"/// \\ \\ ",
|
||||
"// \\ \\",
|
||||
" \\ "
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
vector<string> out;
|
||||
for (const auto& logo : logos) {
|
||||
if (logo.id == distroID) {
|
||||
const string prefix = color(logo.color);
|
||||
const string suffix = color(Color::Reset);
|
||||
for (const auto& line : logo.art) {
|
||||
out.push_back(prefix + line + suffix);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
string getKernel() {
|
||||
struct utsname kernelInfo;
|
||||
|
||||
@@ -168,6 +509,9 @@ string getUptime() {
|
||||
string getShell() {
|
||||
string shell;
|
||||
shell = std::getenv("SHELL");
|
||||
|
||||
while(shell.find('/') < shell.length()) shell.erase(0, shell.find('/') + 1);
|
||||
|
||||
if (!shell.empty()) return shell;
|
||||
|
||||
return "";
|
||||
@@ -241,7 +585,7 @@ string getGPU() {
|
||||
return hex;
|
||||
};
|
||||
|
||||
auto joinWith = [](const std::vector<string>& items, const string& sep) {
|
||||
auto joinWith = [](const vector<string>& items, const string& sep) {
|
||||
string out;
|
||||
for (const auto& item : items) {
|
||||
if (item.empty()) continue;
|
||||
@@ -255,7 +599,7 @@ string getGPU() {
|
||||
|
||||
if(!readPciIds.is_open()) {
|
||||
std::cerr << "Error: Couldn't read /usr/share/hwdata/pci.ids\n";
|
||||
std::vector<string> ids;
|
||||
vector<string> ids;
|
||||
for (const auto& gpu : gpus) {
|
||||
string vendor = normalizeHex(gpu.vendor);
|
||||
string device = normalizeHex(gpu.device);
|
||||
@@ -303,7 +647,7 @@ string getGPU() {
|
||||
|
||||
readPciIds.close();
|
||||
|
||||
std::vector<string> gpuNames;
|
||||
vector<string> gpuNames;
|
||||
for (const auto& gpu : gpus) {
|
||||
string vendor = normalizeHex(gpu.vendor);
|
||||
string device = normalizeHex(gpu.device);
|
||||
@@ -360,7 +704,7 @@ string getRAM() {
|
||||
memkbs /= 1024;
|
||||
float memory = memkbs / 1024.0f;
|
||||
std::stringstream ss;
|
||||
ss << memory << " GB";
|
||||
ss << std::fixed << std::setprecision(2) << memory << " GB";
|
||||
string memGigs = ss.str();
|
||||
|
||||
if (!memGigs.empty()) return memGigs;
|
||||
|
||||
Reference in New Issue
Block a user