From dc1039a73729241e1161d153b50bd83c0a767293 Mon Sep 17 00:00:00 2001 From: Faye Lorenz Date: Tue, 3 Mar 2026 01:53:14 -0600 Subject: [PATCH] init --- .gitignore | 10 ++++++ .python-version | 1 + README.md | 0 espifetch | 7 ++++ info.py | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ logo.py | 22 +++++++++++++ logos/debian.txt | 6 ++++ main.py | 8 +++++ pyproject.toml | 11 +++++++ uv.lock | 47 ++++++++++++++++++++++++++ 10 files changed, 198 insertions(+) create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 README.md create mode 100755 espifetch create mode 100644 info.py create mode 100644 logo.py create mode 100644 logos/debian.txt create mode 100644 main.py create mode 100644 pyproject.toml create mode 100644 uv.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..505a3b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..6324d40 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/espifetch b/espifetch new file mode 100755 index 0000000..92c622d --- /dev/null +++ b/espifetch @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +current_dir=$(pwd) + +cd /opt/espifetch && uv run main.py + +cd $current_dir diff --git a/info.py b/info.py new file mode 100644 index 0000000..234293a --- /dev/null +++ b/info.py @@ -0,0 +1,86 @@ +from colored import Fore, Style +import cpuinfo +import distro +import getpass +import socket +import os + + +def print_info(logo, color): + lines = 1 + for line in logo.split("\n"): + current_line = color + line + Style.reset + match lines: + case 1: + current_line = ( + current_line + + " " + + Fore.red + + "User: " + + Style.reset + + getpass.getuser() + ) + case 2: + current_line = ( + current_line + + " " + + Fore.green + + "Hostname: " + + Style.reset + + socket.gethostname() + ) + case 3: + current_line = ( + current_line + + " " + + Fore.yellow + + "Uptime: " + + Style.reset + + os.popen("uptime -p").read()[:-1] + ) + case 4: + current_line = ( + current_line + + " " + + Fore.blue + + "Distro: " + + Style.reset + + distro.name(pretty=True) + ) + case 5: + current_line = ( + current_line + + " " + + Fore.magenta + + "Kernel: " + + Style.reset + + os.popen("uname -sr").read()[:-1] + ) + case 6: + current_line = ( + current_line + + " " + + Fore.red + + "Terminal: " + + Style.reset + + os.environ["TERM"] + ) + case 7: + current_line = ( + current_line + + " " + + Fore.green + + "Shell: " + + Style.reset + + os.environ["SHELL"] + ) + print(current_line) + lines += 1 + current_line = ( + " " + + Fore.yellow + + "CPU: " + + Style.reset + + cpuinfo.get_cpu_info()["brand_raw"] + ) + print(current_line) diff --git a/logo.py b/logo.py new file mode 100644 index 0000000..c9ac7e9 --- /dev/null +++ b/logo.py @@ -0,0 +1,22 @@ +from colored import Fore, Back, Style +from pathlib import Path + +python_script_path = Path(__file__).parent + + +def set_logo(distro="linux"): + distro_logo_path = None + color = None + match distro: + case "debian": + distro_logo_path = python_script_path / "logos" / "debian.txt" + color = Fore.red + case _: + distro_logo_path = python_script_path / "logos" / "linux.txt" + + return distro_logo_path, color + + +def open_logo_file(path): + with open(path, "r") as f: + return f.read() diff --git a/logos/debian.txt b/logos/debian.txt new file mode 100644 index 0000000..318c569 --- /dev/null +++ b/logos/debian.txt @@ -0,0 +1,6 @@ + _____ + / __ \ +| / | +| \___- +-_ + --_ diff --git a/main.py b/main.py new file mode 100644 index 0000000..7fe8e36 --- /dev/null +++ b/main.py @@ -0,0 +1,8 @@ +import distro +from info import print_info +from logo import set_logo, open_logo_file + +distro_id = distro.id() +logo, color = set_logo(distro_id) + +print_info(open_logo_file(logo), color) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f3ee49b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[project] +name = "espifetch" +version = "0.1.0" +description = "Espifetch is a basic fetch application with radqueer pride flags." +readme = "README.md" +requires-python = ">=3.14" +dependencies = [ + "colored>=2.3.1", + "distro>=1.9.0", + "py-cpuinfo>=9.0.0", +] diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..eff57d7 --- /dev/null +++ b/uv.lock @@ -0,0 +1,47 @@ +version = 1 +revision = 3 +requires-python = ">=3.14" + +[[package]] +name = "colored" +version = "2.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/4a/32/b772def12071faf780dd14e8a95ec8eba4bf5934f302de3a3780b919859a/colored-2.3.1.tar.gz", hash = "sha256:fe6e888e12dc16643daa0b108f785df6d0b48420084b5d0a567de27bb09a14d8", size = 16046, upload-time = "2025-07-31T08:40:05.38Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e4/33/58702880fe6bb3ed91cb21e1c92b002f9b73e32c0c5e3e9e2c0a94eaac61/colored-2.3.1-py3-none-any.whl", hash = "sha256:15d85396d6841f79534bf4668330b5e8686a5e58e730c84ada0e09d335b21fd1", size = 19925, upload-time = "2025-07-31T08:40:03.859Z" }, +] + +[[package]] +name = "distro" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fc/f8/98eea607f65de6527f8a2e8885fc8015d3e6f5775df186e443e0964a11c3/distro-1.9.0.tar.gz", hash = "sha256:2fa77c6fd8940f116ee1d6b94a2f90b13b5ea8d019b98bc8bafdcabcdd9bdbed", size = 60722, upload-time = "2023-12-24T09:54:32.31Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/12/b3/231ffd4ab1fc9d679809f356cebee130ac7daa00d6d6f3206dd4fd137e9e/distro-1.9.0-py3-none-any.whl", hash = "sha256:7bffd925d65168f85027d8da9af6bddab658135b840670a223589bc0c8ef02b2", size = 20277, upload-time = "2023-12-24T09:54:30.421Z" }, +] + +[[package]] +name = "espifetch" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "colored" }, + { name = "distro" }, + { name = "py-cpuinfo" }, +] + +[package.metadata] +requires-dist = [ + { name = "colored", specifier = ">=2.3.1" }, + { name = "distro", specifier = ">=1.9.0" }, + { name = "py-cpuinfo", specifier = ">=9.0.0" }, +] + +[[package]] +name = "py-cpuinfo" +version = "9.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/37/a8/d832f7293ebb21690860d2e01d8115e5ff6f2ae8bbdc953f0eb0fa4bd2c7/py-cpuinfo-9.0.0.tar.gz", hash = "sha256:3cdbbf3fac90dc6f118bfd64384f309edeadd902d7c8fb17f02ffa1fc3f49690", size = 104716, upload-time = "2022-10-25T20:38:06.303Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e0/a9/023730ba63db1e494a271cb018dcd361bd2c917ba7004c3e49d5daf795a2/py_cpuinfo-9.0.0-py3-none-any.whl", hash = "sha256:859625bc251f64e21f077d099d4162689c762b5d6a4c3c97553d56241c9674d5", size = 22335, upload-time = "2022-10-25T20:38:27.636Z" }, +]