Me
  • Home
  • About
  • Projects
  • Resume
  • connect
Connect
Copyright © wan@proline. All rights reserved.
Back to Projects

Pop!_OS Optimization Toolkit

BashPop!_OSNVIDIA CUDADockerROS 2
View Source Code
Pop!_OS Optimization Toolkit

Pop!_OS Optimization Toolkit

Overview

The Pop!_OS Optimization Toolkit is an interactive, terminal-based installer that automatically detects your hardware — CPU, GPU, RAM, laptop model, battery — and delivers tailored configuration for six distinct workload modules: Developer Tools, AI/ML Workstation, Gaming, Robotics (ROS 2), SSH, and System Optimization.

Instead of hunting through dozens of blog posts and wikis, you run one script. It probes your machine, recommends what to install, and lets you toggle individual packages on or off through a polished TUI checklist — nothing is installed without your explicit confirmation.

The entire toolkit is written in pure Bash with zero external dependencies beyond standard coreutils. It accounts for Pop!_OS-specific differences (systemd-boot, kernelstub, system76-power, COSMIC desktop) that break most Ubuntu guides.

Architecture

The project follows a clean modular architecture: a shared library provides all TUI rendering, hardware detection, and installation helpers, while each module script is self-contained and can be run independently or orchestrated through the master installer.

install.sh                      ← Interactive entry point (CLI + menu)
│
├── lib/common.sh               ← Shared TUI library (700 lines)
│   ├── ANSI Color Palette      (Pop!_OS brand-inspired)
│   ├── Box Drawing & Layout    (Unicode box-drawing characters)
│   ├── Hardware Detection      (CPU, GPU, RAM, VRAM, battery, thermals)
│   ├── GPU Tier Classification (ultra / high / medium / entry / minimal)
│   ├── Interactive Menus       (numbered select + toggle checklist)
│   ├── Progress Indicators     (spinner, progress bar)
│   ├── Installation Helpers    (apt, pip, flatpak, snap — all DRY_RUN aware)
│   └── Logging                 (timestamped file + colored terminal output)
│
└── scripts/
    ├── dev-setup.sh            ← Developer Tools (12 package groups)
    ├── ai-setup.sh             ← AI/ML Workstation (8 package groups)
    ├── gaming-setup.sh         ← Gaming Optimization (10 package groups)
    ├── robotics-setup.sh       ← Robotics Lab / ROS 2 (10 package groups)
    ├── ssh-setup.sh            ← SSH Configuration (7 package groups)
    └── system-optimize.sh      ← System Performance (10 package groups)

Hardware Detection Engine

On launch, the toolkit probes the system and builds a complete hardware profile that drives every downstream decision:

  1. Machine Identity — reads DMI data (/sys/devices/virtual/dmi/id/) to identify manufacturer, model, and form factor (laptop vs desktop).
  2. CPU Detection — parses /proc/cpuinfo for model name, core count, and thread count. Intel hybrid architectures (P-cores + E-cores) are recognized for power tuning.
  3. GPU & VRAM — queries lspci and nvidia-smi for GPU model, driver version, CUDA version, and total VRAM. VRAM is classified into tiers (ultra ≥ 24 GB, high ≥ 16 GB, medium ≥ 8 GB, entry ≥ 4 GB, minimal).
  4. Contextual Recommendations — the GPU tier feeds directly into AI model recommendations (e.g., entry-tier GPUs get quantized 3B–7B models, ultra-tier gets 70B+ models).

TUI System

The terminal UI is built from scratch using ANSI escape codes and Unicode box-drawing characters. Key components:

  • System Banner — a bordered profile card showing machine, OS, kernel, CPU, GPU, RAM, storage, and battery.
  • Toggle Checklist — each module presents a checklist where items can be toggled on/off individually, selected all, or deselected all before confirming.
  • Progress Tracking — a Unicode block progress bar (█░) and a braille-character spinner for long-running operations.
  • DRY_RUN Mode — every installation function respects --dry-run, logging what would happen without touching the system.

Modules

1. Developer Tools

A comprehensive development environment with 12 selectable package groups:

GroupPackages
Core Build Toolsgcc, make, cmake, pkg-config, autoconf
Git & Version Controlgit, git-lfs, gh CLI
Python Developmentpython3, pip, venv, dev headers
Node.js & npmNodeSource LTS
Rust Toolchainrustup, cargo, rustc
Go LanguageOfficial PPA
Docker & ComposeDocker Engine + Compose plugin + user group
Terminal Utilitiestmux, htop, btop, neovim, ripgrep, fzf, bat
GUI EditorsVS Code (Flatpak or apt)
Database ToolsPostgreSQL client, SQLite, Redis
Python Data Sciencenumpy, pandas, matplotlib, jupyter
CustomTkinter Stackcustomtkinter, pillow, ttkbootstrap

Each installer detects existing tools first — if docker is already present, it skips reinstallation and shows the current version.

2. AI / ML Workstation

Turns the machine into a local AI inference station with GPU-aware model recommendations.

GroupWhat It Does
NVIDIA Drivers & CUDAsystem76-driver-nvidia, nvidia-cuda-toolkit, nvtop
OllamaLocal LLM engine via llama.cpp backend
Open WebUIDocker-based ChatGPT-style interface on localhost:3000
Python ML StackPyTorch (CUDA or CPU auto-detected), Hugging Face, bitsandbytes
Jupyter LabNotebook environment with dedicated ML kernel
Computer VisionOpenCV, Ultralytics YOLO
LangChain & RAGlangchain, chromadb, sentence-transformers
Text Gen WebUIoobabooga/text-generation-webui

After Ollama installation, the toolkit displays a GPU-tier-aware recommendation table showing which models fit in your VRAM — from TinyLlama 1.1B for entry-tier GPUs to Llama 3.1 70B for ultra-tier cards.

3. Gaming Optimization

Configures native Linux gaming, Steam/Proton, performance overlays, and advanced GPU passthrough.

GroupWhat It Does
SteamClient via apt with i386 architecture
Heroic LauncherEpic Games / GOG on Linux (Flatpak)
LutrisUniversal gaming platform with Wine management
GameModeCPU/GPU game-time optimization daemon
MangoHudFPS overlay with auto-generated config
Vulkan & Mesa32-bit Vulkan runtime, validation layers
ProtonUp-QtCustom Proton/GE-Proton version manager
Wine & DependenciesWine staging + winetricks
GPU Passthrough (KVM)QEMU/KVM + IOMMU via kernelstub (Pop!_OS specific)
Controller SupportXbox, PS4/PS5, Steam controller drivers

The GPU passthrough module is Pop!_OS-aware: it uses kernelstub (not GRUB) for boot parameters, auto-detects Intel vs AMD for the correct IOMMU flag, and verifies IOMMU groups via dmesg.

4. Robotics Lab (ROS 2)

A full ROS 2 Humble Hawksbill environment with 10 selectable component groups:

GroupPackages
ROS 2 Humble DesktopFull desktop install + rosdep init
Navigation 2 StackNav2, SLAM Toolbox, Cartographer, robot_localization
Gazebo SimulationGazebo Classic + ROS 2 integration + ros2_control
TurtleBot3Simulation & real robot support with SLAM demo
MoveIt 2Robotic arm motion planning framework
Arduino / EmbeddedArduino CLI, PlatformIO, pyserial, dialout group
Computer Vision (ROS)cv_bridge, image_transport, depth processing
ROS 2 Dev Toolscolcon, rosdep, vcstool, bloom
Micro-ROSROS 2 for microcontrollers (ESP32, STM32, Pico)
RViz PluginsVisualization tools, rqt, PlotJuggler

The script automatically adds ROS 2 sourcing and colcon autocomplete to ~/.bashrc, sets up a ~/ros2_ws workspace, and configures the TurtleBot3 default model.

5. SSH Configuration

Interactive SSH key management and server hardening:

GroupWhat It Does
Key GenerationEd25519 / RSA 4096 / ECDSA 521 with email prompts
SSH Agentkeychain or fallback ssh-agent auto-start
GitHub SSHPublic key display, clipboard copy, gh CLI integration, connection test
GitLab SSHPublic key display, config setup, connection test
SSH Client ConfigHost aliases, identity file mapping
SSH Server (sshd)OpenSSH server install + hardening
Fail2BanBrute-force protection for sshd

Existing keys are detected and backed up automatically before regeneration. The GitHub module integrates with gh ssh-key add for zero-copy key upload.

6. System Optimization

Low-level performance tuning purpose-built for Pop!_OS:

GroupWhat It Does
Power Profilessystem76-power (Performance / Balanced / Battery) + auto-cpufreq
Thermal Managementlm-sensors, thermald (Intel), live temperature readout
SSD OptimizationWeekly TRIM timer, NVMe health via smartctl, I/O scheduler check
zRAM SwapCompressed RAM swap (zstd algo, 50% of RAM)
Swappiness TuningConfigurable vm.swappiness (default: 10 for workstations) + vfs_cache_pressure
NVIDIA GPU OptimizationPersistence mode, systemd service, power state monitoring
Kernel Boot ParametersPerformance-oriented defaults via kernelstub
Network OptimizationDNS, MTU, TCP tuning
System Monitoringbtop, nvtop, iotop, nethogs
Cleanup & MaintenanceUnused package removal, cache purge

Key Features

Hardware-Aware Intelligence

Every recommendation adapts to your specific machine. A laptop with an RTX A1000 (6 GB) gets different AI model suggestions than a desktop with an RTX 4090 (24 GB). Battery-equipped machines get power management profiles. Intel hybrid CPUs get auto-cpufreq for P-core/E-core scheduling.

Interactive Checklist UI

No all-or-nothing installs. Each module presents a toggle checklist rendered with Unicode box-drawing characters. Select exactly what you need, confirm, and watch a progress bar track each group.

DRY_RUN Mode

Run ./install.sh --dry-run to preview every apt install, pip install, and flatpak install that would execute — without touching your system. Every installation helper function checks the DRY_RUN flag.

Pop!_OS Native

The toolkit understands Pop!_OS internals that differ from Ubuntu:

ConcernPop!_OS Approach
Boot parameterskernelstub -a "param" (not update-grub)
Power managementsystem76-power (not TLP)
NVIDIA driversPre-installed via NVIDIA ISO
DesktopCOSMIC (GNOME fork)
RecoveryBuilt-in refresh/reinstall partition

CLI + Interactive Dual Modes

Run interactively with the full TUI menu, or script it via CLI flags:

./install.sh                  # Interactive menu
./install.sh --dev --ai       # Non-interactive: specific modules
./install.sh --all            # Non-interactive: everything
./install.sh --dry-run --all  # Preview everything

Full Logging

Every operation is timestamped and written to /tmp/pop-os-toolkit-YYYYMMDD-HHMMSS.log. Terminal output is color-coded: [INFO] cyan, [OK] green, [WARN] yellow, [FAIL] red.

Reference Hardware

Developed and tested on a Lenovo ThinkPad P-Series workstation laptop:

ComponentSpecification
CPUIntel Core i9-13950HX — 24 cores (8P + 16E), 32 threads, 5.4 GHz
GPUNVIDIA RTX A1000 6 GB — Ampere, CUDA 8.6, ISV-certified
RAM32 GB DDR5 (dual-channel)
Storage1 TB NVMe SSD (PCIe Gen4)
OSPop!_OS 22.04 LTS (NVIDIA ISO)

Hardware detection adapts automatically for other machines — the toolkit has been designed with manufacturer-specific greetings for Lenovo, Dell, HP, System76, ASUS, Acer, and MSI systems.

Tech Stack

LayerTechnology
LanguageBash 5.x (POSIX-compliant where possible)
Target OSPop!_OS 22.04 LTS (Ubuntu 22.04 Jammy base)
TUI RenderingANSI escape codes + Unicode box-drawing
Package Managersapt, pip, flatpak, snap, cargo, rustup
ContainerizationDocker Engine + Compose
AI InferenceOllama (llama.cpp), PyTorch, CUDA
RoboticsROS 2 Humble, Gazebo, Nav2, MoveIt 2
GPU StackNVIDIA drivers, CUDA Toolkit, Vulkan
Version ControlGit, GitHub CLI

Project Structure

pop-os-linux-optimisation/
├── install.sh                  # Master interactive installer (entry point)
├── lib/
│   └── common.sh               # Shared TUI library — colors, menus, hardware detection
├── scripts/
│   ├── dev-setup.sh             # Developer tools (12 groups, 310 lines)
│   ├── ai-setup.sh              # AI/ML workstation (8 groups, 434 lines)
│   ├── gaming-setup.sh          # Gaming optimization (10 groups, 429 lines)
│   ├── robotics-setup.sh        # Robotics lab / ROS 2 (10 groups, 428 lines)
│   ├── ssh-setup.sh             # SSH configuration (7 groups, 680 lines)
│   └── system-optimize.sh       # System performance (10 groups, 558 lines)
├── ai/
│   └── README.md                # AI/ML workstation deep-dive guide
├── gaming/
│   └── README.md                # Gaming optimization deep-dive guide
├── robotics/
│   └── README.md                # ROS 2 robotics deep-dive guide
└── dev-tools/
    └── dev-setup.sh             # Legacy script (superseded by scripts/)
Avatar 01Avatar 02Avatar 03Avatar 04Avatar 05
Never miss an update!

connect and join 100K+ developers.

*Sponsor
Build The Site You Want!

Your website should be an asset, not an engineering challenge.