Skip to content

Commit

Permalink
Add a button that reboots the device to bootloader (#137)
Browse files Browse the repository at this point in the history
* Dummy version change to create and test develop branch
* Fix develop release flow
* Add a button that reboots the device to bootloader

---------

Co-authored-by: CryoByte33 <[email protected]>
  • Loading branch information
man90es and CryoByte33 authored Nov 29, 2023
1 parent 8fd9ac5 commit 841f780
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/ui_tab.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,12 @@ func (app *Config) vramTab() *fyne.Container {
// Get VRAM value
app.refreshVRAMContent()

textHowTo := widget.NewLabel("1. Turn off the Steam Deck\n\n" +
"2. Press and hold the volume up button, press the power button, then release both\n\n" +
"3. Navigate to Setup Utility -> Advanced -> UMA Frame Buffer Size")

textHowTo := widget.NewLabel("1. Press the button below to reboot to bootloader\n\n" +
"2. Navigate to Setup Utility -> Advanced -> UMA Frame Buffer Size")

textRecommended := widget.NewLabelWithStyle("4G is the recommended setting for most situations", fyne.TextAlignLeading, fyne.TextStyle{Bold: true})
textWarning := widget.NewLabel("Please be aware that some games (RDR2) may experience degraded performance.")


textVBox := container.NewVBox(
textHowTo,
textRecommended,
Expand All @@ -303,6 +301,12 @@ func (app *Config) vramTab() *fyne.Container {

vramCard := widget.NewCard("Minimum VRAM", "How to change the minimum VRAM:", textVBox)

rebootToBootloaderButton := widget.NewButton("Reboot to bootloader", func() {
if err := rebootToBootloader(); err != nil {
rebootFailedWindow()
}
})

vramBAR := container.NewGridWithColumns(1,
container.NewCenter(app.VRAMText))
topBar := container.NewVBox(
Expand All @@ -313,6 +317,7 @@ func (app *Config) vramTab() *fyne.Container {

vramVBOX := container.NewVBox(
vramCard,
rebootToBootloaderButton,
)
scroll := container.NewScroll(vramVBOX)
full := container.NewBorder(topBar, nil, nil, nil, scroll)
Expand Down
22 changes: 22 additions & 0 deletions internal/ui_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,3 +461,25 @@ func swappinessWindow() {
w.RequestFocus()
w.Show()
}

func rebootFailedWindow() {
// Create a new window
w := CryoUtils.App.NewWindow("Reboot to bootloader failed")

// Place a prompt near the top of the window
prompt := canvas.NewText("Please reboot to bootloader manually:", nil)
prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}

textHowTo := widget.NewLabel("1. Turn off the Steam Deck\n\n" +
"2. Press and hold the volume up button, press the power button, then release both")

// Provide a button to close the window
closeButton := widget.NewButton("Ok", w.Close)

swapVBox := container.NewVBox(prompt, textHowTo, closeButton)
w.SetContent(swapVBox)
w.Resize(fyne.NewSize(400, 150))
w.CenterOnScreen()
w.RequestFocus()
w.Show()
}
11 changes: 11 additions & 0 deletions internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,14 @@ func removeGameData(removeList []string, locations []string) {
}
}
}

func rebootToBootloader() error {
CryoUtils.InfoLog.Println("Rebooting to bootloader")

_, err := exec.Command("systemctl", "reboot", "--firmware-setup").Output()
if err != nil {
return fmt.Errorf("error rebooting to bootloader")
}

return nil
}

0 comments on commit 841f780

Please sign in to comment.