Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bbe703ec1 | |||
| d8bc65e0d6 | |||
| 7abb846a81 | |||
| 58bcb147e4 | |||
| ecf066dcb3 | |||
| e6e5648a2d | |||
| e47dc4f7d8 | |||
| 07aad4b651 | |||
| 69f97442a3 | |||
| 0b07013eeb |
@@ -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,64 @@
|
||||
# fetchit
|
||||
Works on my machine
|
||||
|
||||
fetchit is a terminal-based system information viewer written in C++. It works like neofetch/fastfetch and consists of a single file (`main.cpp`).
|
||||
|
||||
## Features
|
||||
|
||||
- Displays distro, kernel, uptime, shell, CPU, GPU, RAM, and OS date information.
|
||||
- Detects distro name via `/etc/os-release`.
|
||||
- Shows ASCII logos for supported distros.
|
||||
- Reads `/usr/share/hwdata/pci.ids` for GPU names; prints hex IDs if missing.
|
||||
- Accounts for Unicode character width (for icon alignment).
|
||||
|
||||
## Supported Distro Logos
|
||||
|
||||
`arch`, `cachyos`, `debian`, `ubuntu`, `fedora`, `manjaro`, `opensuse`, `pop`, `linuxmint`, `endeavouros`, `void`, `alpine`
|
||||
|
||||
## Requirements
|
||||
|
||||
- Linux
|
||||
- A C++17-capable compiler (e.g., g++)
|
||||
- A UTF-8 terminal with ANSI color support (for icons and colors)
|
||||
- The following files/paths are read:
|
||||
- `/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
|
||||
|
||||
```bash
|
||||
g++ -std=c++17 -O2 -o fetchit main.cpp
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
./fetchit
|
||||
```
|
||||
|
||||
## Sample Output
|
||||
|
||||
```text
|
||||
--- murat@baklava ---
|
||||
|
||||
/\ distro: Arch Linux
|
||||
/ \ kernel: 7.0.10-arch1-1
|
||||
/ \ uptime: 1 minutes
|
||||
/ \ shell: /usr/bin/bash
|
||||
/ ,, \ CPU: 12th Gen Intel(R) Core(TM) i5-12500H (16) @ 4.5 GHz
|
||||
/ | | \ GPU: AD107M [GeForce RTX 4060 Max-Q / Mobile] / Alder Lake-P GT2 [Iris Xe Graphics]
|
||||
/_-'' ''-_\ RAM: 15.2529 GB
|
||||
OS Date: 6 months 17 days 3 hours 40 minutes
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- `OS Date` is based on the creation time of `/etc/hostname`.
|
||||
- If no ASCII logo is found, only the info list is printed.
|
||||
- The distro logo is displayed in color via ANSI escape codes.
|
||||
- This tool targets Linux systems and is not expected to work on non-Linux OSes.
|
||||
|
||||
@@ -334,28 +334,26 @@ std::vector<string> distroArt() {
|
||||
"ubuntu",
|
||||
Color::Orange,
|
||||
{
|
||||
"------ |\\ ", // TODO:
|
||||
" | | \\ ",
|
||||
" | | / ",
|
||||
" | |/ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
" _ ",
|
||||
" ,--(_) ",
|
||||
" _/ ;-._\\ ",
|
||||
"(_)( ) )",
|
||||
" \\ ;-'_/ ",
|
||||
" `--(_) "
|
||||
}
|
||||
},
|
||||
{
|
||||
"fedora",
|
||||
Color::Blue,
|
||||
{
|
||||
"------ |\\ ", // TODO:
|
||||
" | | \\ ",
|
||||
" | | / ",
|
||||
" | |/ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "
|
||||
" _____ ",
|
||||
" / __)\\ ",
|
||||
" | / \\ \\",
|
||||
" ___| |__/ /",
|
||||
" / (_ _)_/ ",
|
||||
"/ / | | ",
|
||||
"\\ \\__/ | ",
|
||||
" \\(_____/ ",
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -388,7 +386,7 @@ std::vector<string> distroArt() {
|
||||
},
|
||||
{
|
||||
"pop",
|
||||
Color::Purple,
|
||||
Color::Cyan,
|
||||
{
|
||||
"______ ",
|
||||
"\\ _ \\ __",
|
||||
@@ -428,7 +426,7 @@ std::vector<string> distroArt() {
|
||||
},
|
||||
{
|
||||
"void",
|
||||
Color::Gray,
|
||||
Color::Green,
|
||||
{
|
||||
" ____ ",
|
||||
" 'pfPfp.% ",
|
||||
@@ -453,12 +451,9 @@ std::vector<string> distroArt() {
|
||||
},
|
||||
};
|
||||
|
||||
// Ubuntu: Orange (+ Light/Deep Orange)
|
||||
// Fedora: Blue + Gray/White
|
||||
|
||||
std::vector<string> out;
|
||||
for (const auto& logo : logos) {
|
||||
if (logo.id == "alpine") {
|
||||
if (logo.id == distroID) {
|
||||
const string prefix = color(logo.color);
|
||||
const string suffix = color(Color::Reset);
|
||||
for (const auto& line : logo.art) {
|
||||
|
||||
Reference in New Issue
Block a user