Gracefully shut down the program when we are done
This commit is contained in:
parent
7affa8d06d
commit
be3bcb02f7
2 changed files with 19 additions and 5 deletions
|
@ -14,8 +14,10 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
|
|
||||||
case "enter":
|
case "enter":
|
||||||
if m.loaded {
|
if m.loaded {
|
||||||
// Process the selected item
|
// Process the selected item, if the return value is true then exit the application
|
||||||
m.processSelection()
|
if m.processSelection() {
|
||||||
|
return m, tea.Quit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "ctrl+z", "backspace":
|
case "ctrl+z", "backspace":
|
||||||
// Go backwards in the model
|
// Go backwards in the model
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
"github.com/HikariKnight/quickpassthrough/internal/configs"
|
||||||
|
@ -9,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// This function processes the enter event
|
// This function processes the enter event
|
||||||
func (m *model) processSelection() {
|
func (m *model) processSelection() bool {
|
||||||
switch m.focused {
|
switch m.focused {
|
||||||
case GPUS:
|
case GPUS:
|
||||||
// Gets the selected item
|
// Gets the selected item
|
||||||
|
@ -65,24 +64,37 @@ func (m *model) processSelection() {
|
||||||
// Gets the selected item
|
// Gets the selected item
|
||||||
selectedItem := m.lists[m.focused].SelectedItem()
|
selectedItem := m.lists[m.focused].SelectedItem()
|
||||||
|
|
||||||
|
// If user selected yes then
|
||||||
if selectedItem.(item).title == "YES" {
|
if selectedItem.(item).title == "YES" {
|
||||||
|
// Add disable VFIO video to the config
|
||||||
m.disableVFIOVideo()
|
m.disableVFIOVideo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Configure modprobe
|
||||||
|
configs.Set_Modprobe()
|
||||||
|
|
||||||
|
// Go to the next view
|
||||||
m.focused++
|
m.focused++
|
||||||
|
|
||||||
case INTRO:
|
case INTRO:
|
||||||
// This is an OK Dialog
|
// This is an OK Dialog
|
||||||
// Create the config folder and the files related to this system
|
// Create the config folder and the files related to this system
|
||||||
configs.InitConfigs()
|
configs.InitConfigs()
|
||||||
|
|
||||||
|
// Go to the next view
|
||||||
m.focused++
|
m.focused++
|
||||||
|
|
||||||
case DONE:
|
case DONE:
|
||||||
os.Exit(0)
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *model) disableVFIOVideo() {
|
func (m *model) disableVFIOVideo() {
|
||||||
// Get the config
|
// Get the config
|
||||||
config := configs.GetConfig()
|
config := configs.GetConfig()
|
||||||
|
|
||||||
|
// Add to the kernel arguments that we want to disable VFIO video output on the host
|
||||||
fileio.AppendContent(" vfio_pci.disable_vga=1", config.Path.CMDLINE)
|
fileio.AppendContent(" vfio_pci.disable_vga=1", config.Path.CMDLINE)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue