Start process to away from bubbletea to a more simpler solution for this projects needs

This commit is contained in:
HikariKnight 2023-10-26 20:03:15 +02:00
parent cc6db38d74
commit c1ea5e5163
10 changed files with 298 additions and 65 deletions

View file

@ -0,0 +1,39 @@
package pages
import (
"github.com/HikariKnight/quickpassthrough/pkg/command"
"github.com/HikariKnight/quickpassthrough/pkg/menu"
"github.com/gookit/color"
)
// Welcome page
func Welcome() {
// Clear screen
command.Clear()
// Write title
color.Bold.Println("Welcome to Quickpassthrough!")
// Write welcome message
color.Println(
" This script is meant to make it easier to setup GPU passthrough for\n",
"Qemu based systems. WITH DIFFERENT 2 GPUS ON THE HOST SYSTEM\n",
"However due to the complexity of GPU passthrough\n",
"This script assumes you know how to do (or have done) the following.\n\n",
"* You have already enabled IOMMU, VT-d, SVM and/or AMD-v\n inside your UEFI/BIOS advanced settings.\n",
"* Know how to edit your bootloader\n",
"* Have a bootloader timeout of at least 3 seconds to access the menu\n",
"* Enable & Configure kernel modules\n",
"* Have a backup/snapshot of your system in case the script causes your\n system to be unbootable\n\n",
"By continuing you accept that I am not liable if your system\n",
"becomes unbootable, as you will be asked to verify the files generated\n",
)
// Make user accept responsibility
choice := menu.YesNo("Are you sure you want to continue?")
// If yes, go to next page
if choice == "y" {
SelectGPU()
}
}

View file

@ -0,0 +1,72 @@
package pages
import (
"fmt"
lsiommu "github.com/HikariKnight/quickpassthrough/internal/lsiommu"
"github.com/HikariKnight/quickpassthrough/pkg/command"
"github.com/HikariKnight/quickpassthrough/pkg/menu"
"github.com/gookit/color"
)
func SelectGPU() {
// Clear the screen
command.Clear()
// Get the users GPUs
gpus := lsiommu.GetIOMMU("-g", "-F", "vendor:,prod_name,optional_revision:,device_id")
// Generate a list of choices based on the GPUs and get the users selection
choice := menu.GenIOMMUMenu("Select a GPU to view the IOMMU groups of", gpus)
// View the selected GPU
ViewGPU(choice)
}
func ViewGPU(id string, ext ...int) {
// Clear the screen
command.Clear()
// Set mode to relative
mode := "-r"
// Set mode to relative extended
if len(ext) > 0 {
mode = "-rr"
}
// Get the IOMMU listings for GPUs
group := lsiommu.GetIOMMU("-g", mode, "-i", id, "-F", "vendor:,prod_name,optional_revision:,device_id")
// Write a title
color.Bold.Println("This list should only show devices related to your GPU")
// Print all the gpus
for _, v := range group {
fmt.Println(v)
}
// Add a new line for tidyness
fmt.Println("")
// Make an empty string
var choice string
// Change choices depending on if we have done an extended search or not
if len(ext) > 0 {
choice = menu.YesNo("Use this GPU (any extra devices listed may or may not be linked to it) for passthrough?")
} else {
choice = menu.YesNoEXT("Use this GPU (and related devices) for passthrough?")
}
// Parse the choice
switch choice {
case "ext":
// Run an extended relative search
ViewGPU(id, 1)
case "n":
// Go back to selecting a gpu
SelectGPU()
}
}