Skip to content

Conversation

@xcrsz
Copy link
Contributor

@xcrsz xcrsz commented Sep 30, 2025

Summary by Sourcery

Add dynamic menu generation for xconfig and improve GPU and virtualization assignment logic

New Features:

  • Implement interactive bsddialog/dialog menus built dynamically for manual configuration selection
  • Enhance automatic GPU detection to classify and install the appropriate Intel, AMD, and multiple NVIDIA driver branches
  • Add virtualization detection with automatic configuration for VirtualBox, VMware, QEMU/KVM, Hyper-V, and fallback options
  • Support offline driver installation from /xdrivers before falling back to pkg repos

Enhancements:

  • Include new Xorg config templates for amdgpu, radeonkms, Intel, dual-monitor, Hyper-V, safe recovery, and other scenarios

Documentation:

  • Revamp README with detailed hardware support, installation steps, usage examples, and offline driver instructions

…ompatibility

Replace unmaintainable bash-dependent script with POSIX sh compatible version
that uses modern hardware detection instead of massive hardcoded device lists.

GPU detection overhaul:
- PCI vendor ID detection: 0x10de (NVIDIA), 0x1002 (AMD), 0x8086 (Intel)
- Device ID range mapping instead of 2000+ hardcoded GPU model strings
- Eliminated maintenance burden of updating lists for every new GPU release
- Future-proof design that works with unreleased hardware

NVIDIA improvements:
- Real package detection: nvidia-driver-580/470/390/340/304/devel
- Device ID range-based driver selection (RTX 50/40/30→580, RTX 20→470, etc.)
- Automatic Linux compatibility layer setup and module loading
- Proper nvidia-modeset vs nvidia module selection by driver version

AMD enhancements:
- Smart amdgpu vs radeonkms detection using device ID ranges
- Newer cards (0x6900+) → amdgpu, legacy cards → radeonkms
- Automatic kernel module loading and conflict resolution

Intel graphics:
- i915kms module loading with proper conflict handling
- Auto-detection fallback when module loading fails
- Enhanced compatibility across Intel GPU generations

Shell compatibility fixes:
- POSIX sh compatible (works with sh, zsh, fish - no bash dependency)
- Eliminated $((...)) arithmetic and bash-specific syntax causing usage errors
- Progressive fallback: auto-detection → hardware-specific → VESA → manual

VirtualBox testing:
- Confirmed working on FreeBSD in VirtualBox environment
- Proper guest additions setup and service configuration
- Eliminates "pkg: No package(s) matching nvidia-driver" errors

Reduces codebase from 800+ lines of unmaintainable device lists to 400 lines
of future-proof, hardware-agnostic detection logic.
Key changes:
- Consistent -ignoreABI usage throughout all X configuration generation
- Added test_x_config() function that uses -ignoreABI for testing configurations
- Enhanced configuration testing in manual setup mode
- Added IgnoreABI option to VESA config for consistency
- Improved VMware setup with configuration testing and fallback
- Enhanced system state check that tests X server responsiveness
- Better error handling in X configuration generation
Improvements:
- FreeBSD paths: /usr/local/etc/X11/xorg.conf (proper FreeBSD standard)
- Kernel modules: Fixed sysrc kld_list handling with deduplication and persistence
- NVIDIA: Removed unnecessary Linux compat, smart package fallback logic
- X testing: Eliminated timeout dependency, uses vt9 for safe testing
- Modern defaults: Prefers Xorg autoconfig, only writes xorg.conf when necessary
- Code quality: Proper POSIX sh with set -eu, FreeBSD-specific sed syntax
Improvements:

- Added ServerLayout with proper InputDevice references, InputDevice sections
- Added DPMS support and better descriptions for ModeLine entries
- Added ShadowFB true and DefaultRefresh 60 options
- Added 8-bit depth, organized color depth sections
Improvements:
- Added all missing sections (ServerLayout, Files, Module, InputDevice, Screen)
- Proper Cirrus driver configuration with appropriate options
- Limited to what QEMU/Cirrus can reliably handle
Improvements:
- Added standard Files and Module sections
- Enhanced with proper VirtualBox vendor info and wider sync ranges
- Added ShadowFB false and VESA false options
- Support for 1920x1080, 1680x1050, etc.
Improvements:
-Missing closing quote in "AutoAddDevices" "Off → "Off"
- Added Files, Module, InputDevice (Keyboard), complete Monitor section
- Added multiple color depths and modern resolutions
- Added HWcursor false and StaticXinerama false options
- Xinerama support for multi-monitor
- Side-by-side monitor configuration
- Alternative single-card dual-output setup
- Includes configuration comments and examples
- SCFB driver with shadow framebuffer
- Wide sync ranges for dynamic resolution
- Enterprise virtualization support
- Glamor acceleration
- Color tiling and page flipping
- DRI2 support
- Standard resolution support
- SNA acceleration method
- TearFree option for smooth video
- DRI3 support
- Modern resolution support
- Added Hyper-V detection
- Enhanced Intel support with both auto-detection and config file options
- Improved AMD support by using appropriate external config files

Additional setup functions:
- setup_intel_config() - Uses external Intel config
- setup_hyperv() - Microsoft Hyper-V support
- setup_safe() - Safe/recovery mode
- setup_dual() - Dual monitor template

- Graceful fallbacks when external configs aren't available
@xcrsz xcrsz requested review from a team as code owners September 30, 2025 15:03
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 30, 2025

Reviewer's Guide

This PR enriches xconfig with a complete user guide, implements dynamic menu generation in the script, enhances GPU detection and driver assignment logic (including NVIDIA branch heuristics and AMD auto-selection), and adds new external configuration templates for multiple scenarios.

Class diagram for dynamic menu generation and GPU assignment logic

classDiagram
    class XConfig {
      +autoDetectHardware()
      +generateDynamicMenu()
      +applyConfiguration(template)
      +installDriver(driver)
      +backupXorgConf()
      +selectNvidiaBranch()
      +selectAmdBranch()
    }
    class Menu {
      +options
      +buildMenu(options)
      +showMenu()
    }
    class GPU {
      +type
      +driver
      +detectType()
      +assignDriver()
    }
    class ConfigTemplate {
      +name
      +path
      +apply()
    }
    XConfig --> Menu : uses
    XConfig --> GPU : detects/assigns
    XConfig --> ConfigTemplate : applies
Loading

File-Level Changes

Change Details Files
Expanded README with full documentation
  • Rewritten project description with badges and detailed overview
  • Added sections for installation, usage modes, targets, and offline drivers
  • Documented external template locations, backup behavior, and NVIDIA heuristic
README.md
Enhanced xconfig script logic
  • Built interactive menus dynamically via bsddialog/dialog and safe set -- invocation
  • Improved GPU detection with AMD auto-classification and NVIDIA branch selection heuristic
  • Added offline installation from /xdrivers/drivers-list with pkg fallback
  • Implemented timestamped backups of existing xorg.conf before applying templates
bin/xconfig
Added new external configuration templates
  • Introduced templates for modern AMD (amdgpu), dual monitors, and safe mode
  • Added legacy AMD (radeonkms), Intel, Hyper-V, and other virtualization templates
cardDetect/XF86Config.amdgpu
cardDetect/XF86Config.dual
cardDetect/XF86Config.hyperv
cardDetect/XF86Config.intel
cardDetect/XF86Config.radeonkms
cardDetect/XF86Config.safe

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Refactor the GPU classification and driver branch selection logic in bin/xconfig into dedicated helper functions to improve readability and ease future enhancements.
  • Add existence checks for cardDetect templates before including them in the interactive menu to avoid presenting missing or stale entries.
  • Ensure dynamic menu entries are properly quoted and escaped to handle any special characters in template filenames safely.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Refactor the GPU classification and driver branch selection logic in bin/xconfig into dedicated helper functions to improve readability and ease future enhancements.
- Add existence checks for cardDetect templates before including them in the interactive menu to avoid presenting missing or stale entries.
- Ensure dynamic menu entries are properly quoted and escaped to handle any special characters in template filenames safely.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@ericbsd ericbsd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation bot moved this from In Review to In Progress in Development Tracker Oct 1, 2025
@ericbsd ericbsd merged commit 8acb30e into ghostbsd:master Oct 1, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Development Tracker Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants