diff --git a/README.org b/README.org new file mode 100644 index 0000000..00071e6 --- /dev/null +++ b/README.org @@ -0,0 +1,2 @@ +* Espifetch +Espifetch is a basic fetch application with radqueer pride flags. diff --git a/espifetch b/espifetch index 92c622d..3c23772 100755 --- a/espifetch +++ b/espifetch @@ -1,7 +1,10 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 -current_dir=$(pwd) +import distro +from logo_scripts import debian +from pathlib import Path -cd /opt/espifetch && uv run main.py - -cd $current_dir +if distro.id() == "debian": + debian.print_debian(Path(__file__).parent) +else: + print("Distro not supported.") diff --git a/info.py b/info.py deleted file mode 100644 index 234293a..0000000 --- a/info.py +++ /dev/null @@ -1,86 +0,0 @@ -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 deleted file mode 100644 index c9ac7e9..0000000 --- a/logo.py +++ /dev/null @@ -1,22 +0,0 @@ -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/README.md b/logo_scripts/__init__.py similarity index 100% rename from README.md rename to logo_scripts/__init__.py diff --git a/logo_scripts/debian.py b/logo_scripts/debian.py new file mode 100644 index 0000000..05d6f38 --- /dev/null +++ b/logo_scripts/debian.py @@ -0,0 +1,40 @@ +from colored import Fore, Style +import cpuinfo +import distro +import getpass +import os +import socket +import subprocess + + +logo_color = Fore.red +color1 = Fore.red +color2 = Fore.green +color3 = Fore.yellow +color4 = Fore.blue +color5 = Fore.magenta + +def print_debian(main_dir): + current_line = 1 + logo = open(main_dir / "logos" / "debian.txt", "r").read().split("\n") + for line in logo: + colored_line = str(logo_color) + line + Style.reset + match current_line: + case 1: + colored_line = colored_line + " " + color1 + "User: " + Style.reset + getpass.getuser() + case 2: + colored_line = colored_line + " " + color2 + "Hostname: " + Style.reset + socket.gethostname() + case 3: + colored_line = colored_line + " " + color3 + "Uptime: " + Style.reset + subprocess.run(['uptime', '-p'], capture_output=True, text=True, check=True).stdout[:-1] + case 4: + colored_line = colored_line + " " + color4 + "Distro: " + Style.reset + distro.name(pretty=True) + case 5: + colored_line = colored_line + " " + color5 + "Kernel: " + Style.reset + subprocess.run(['uname', '-sr'], capture_output=True, text=True, check=True).stdout[:-1] + case 6: + colored_line = colored_line + " " + color1 + "Terminal: " + Style.reset + os.environ["TERM"] + case 7: + colored_line = colored_line + " " + color2 + "Shell: " + Style.reset + os.environ["SHELL"] + print(colored_line, '') + current_line += 1 + colored_line = " " + str(color3) + "CPU: " + Style.reset + cpuinfo.get_cpu_info()["brand_raw"] + print(colored_line) diff --git a/main.py b/main.py deleted file mode 100644 index 7fe8e36..0000000 --- a/main.py +++ /dev/null @@ -1,8 +0,0 @@ -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 index f3ee49b..402dbf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "espifetch" version = "0.1.0" description = "Espifetch is a basic fetch application with radqueer pride flags." -readme = "README.md" +readme = "README.org" requires-python = ">=3.14" dependencies = [ "colored>=2.3.1",