From a934c66ffa9a1269aa5c5e1c19a6e25d784ccf08 Mon Sep 17 00:00:00 2001 From: CryoByte33 Date: Sat, 25 Nov 2023 11:08:38 +0100 Subject: [PATCH] OLED model compatibility! (#165) * Improve launcher.sh script (#155) Use grep with -c flag instead of wc -l command. Additionally, change quotation of path pointing to cryo_utilities binary. Signed-off-by: skaluzka * Single quotes for manual installation script. (#125) * Single quotes For me echo only worked with single quotes. * Make sure "$HOME"/.local/share/applications exists * Update scaling logic for OLED --------- Signed-off-by: skaluzka Co-authored-by: skaluzka <34603480+skaluzka@users.noreply.github.com> Co-authored-by: Tobias Domhan --- README.md | 10 +++++-- docs/manual-install.md | 27 +++++++++---------- internal/config.go | 2 +- internal/ui_screen.go | 59 +++++++++++++++++------------------------- launcher.sh | 7 ++--- 5 files changed, 49 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index bb1f2c5..c83125b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ Scripts and utilities to improve performance and manage storage on the Steam Dec ## Update +### Notes on the Steam Deck OLED +The latest update resolves the scaling issues on the new OLED Deck, and I figured I should provide an update here: +1. **This (CU2) is still fully compatible with the new OLED models.** +2. Performance improvements should be similar (or possibly slightly better) than on the LCD model (thorough testing pending) + ### General Linux Compatibility As of the latest update, this _should_ be compatible with most Linux systems, with the following limitations: 1. This will not operate on swap partitions, only files. @@ -55,7 +60,7 @@ new features and how they work. * Storage Manager * Sync shadercache and compatdata to the same location the game is installed * Delete shadercache and compatdata for whichever games you select - * **NEW** Delete the shadercache and compatdata for all uninstalled games with a single click + * Delete the shadercache and compatdata for all uninstalled games with a single click * Full CLI mode Look below for common questions and answers, or go check out my [YouTube Channel](https://www.youtube.com/@cryobyte33) @@ -66,7 +71,8 @@ for examples on how to use this and what performance you can expect. ### Simple [Download this link](https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/InstallCryoUtilities.desktop) -to your desktop (right click and save file) on your Steam Deck, then double-click it. +to your desktop (right click and save file) on your Steam Deck, remove the `.download` from the end of the file name, +then double-click it. This will install the program, create desktop icons, and create menu entries. diff --git a/docs/manual-install.md b/docs/manual-install.md index dde79a3..8c80d99 100644 --- a/docs/manual-install.md +++ b/docs/manual-install.md @@ -8,8 +8,8 @@ cd .cryo_utilities ``` 2. Go to [the releases page](https://github.com/CryoByte33/steam-deck-utilities/releases/tag/latest) and download cryo_utilities. 3. Go to [launcher.sh](https://github.com/CryoByte33/steam-deck-utilities/blob/main/launcher.sh), right click on "Raw" and "Save Link As" to the downloads folder. -4. Go to [icon.png](https://github.com/CryoByte33/steam-deck-utilities/blob/main/icon.png), right click on "Raw" and "Save Link As" to the downloads folder. -5. Move all 3 downloaded files to `/home/deck/cryo_utilities`. +4. Go to [icon.png](https://github.com/CryoByte33/steam-deck-utilities/blob/main/icon.png), right click on "Raw" and "Save Link As" to the downloads folder naming it `cryo-utilities.png`. +5. Move all 3 downloaded files to `/home/deck/.cryo_utilities`. 6. Open Konsole and paste the entire block below, then press Enter/Return: ```bash cd ~/.cryo_utilities @@ -27,27 +27,28 @@ Type=Application StartupNotify=false' >"$HOME"/Desktop/CryoUtilitiesUninstall.desktop chmod +x "$HOME"/Desktop/CryoUtilitiesUninstall.desktop rm -rf "$HOME"/Desktop/CryoUtilities.desktop 2>/dev/null -echo "#!/usr/bin/env xdg-open +echo '#!/usr/bin/env xdg-open [Desktop Entry] Name=CryoUtilities Exec=bash $HOME/.cryo_utilities/launcher.sh Icon=cryo-utilities Terminal=false Type=Application -StartupNotify=false" >"$HOME"/Desktop/CryoUtilities.desktop +StartupNotify=false' >"$HOME"/Desktop/CryoUtilities.desktop chmod +x "$HOME"/Desktop/CryoUtilities.desktop rm -rf "$HOME"/Desktop/UpdateCryoUtilities.desktop 2>/dev/null -echo "#!/usr/bin/env xdg-open +mkdir -p "$HOME"/.local/share/applications +echo '#!/usr/bin/env xdg-open [Desktop Entry] Name=Update CryoUtilities Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s -- Icon=bittorrent-sync Terminal=false Type=Application -StartupNotify=false" >"$HOME"/Desktop/UpdateCryoUtilities.desktop +StartupNotify=false' >"$HOME"/Desktop/UpdateCryoUtilities.desktop chmod +x "$HOME"/Desktop/UpdateCryoUtilities.desktop rm -rf "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop 2>/dev/null -echo "#!/usr/bin/env xdg-open +echo '#!/usr/bin/env xdg-open [Desktop Entry] Name=CryoUtilities - Uninstall Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/uninstall.sh | bash -s -- @@ -55,10 +56,10 @@ Icon=delete Terminal=false Type=Application Categories=Utility -StartupNotify=false" >"$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop +StartupNotify=false' >"$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop chmod +x "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop rm -rf "$HOME"/.local/share/applications/CryoUtilities.desktop 2>/dev/null -echo "#!/usr/bin/env xdg-open +echo '#!/usr/bin/env xdg-open [Desktop Entry] Name=CryoUtilities Exec=bash $HOME/.cryo_utilities/launcher.sh @@ -66,10 +67,10 @@ Icon=cryo-utilities Terminal=false Type=Application Categories=Utility -StartupNotify=false" >"$HOME"/.local/share/applications/CryoUtilities.desktop +StartupNotify=false' >"$HOME"/.local/share/applications/CryoUtilities.desktop chmod +x "$HOME"/.local/share/applications/CryoUtilities.desktop rm -rf "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop 2>/dev/null -echo "#!/usr/bin/env xdg-open +echo '#!/usr/bin/env xdg-open [Desktop Entry] Name=CryoUtilities - Update Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s -- @@ -77,8 +78,8 @@ Icon=bittorrent-sync Terminal=false Type=Application Categories=Utility -StartupNotify=false" >"$HOME"/.local/share/applications/UpdateCryoUtilities.desktop +StartupNotify=false' >"$HOME"/.local/share/applications/UpdateCryoUtilities.desktop chmod +x "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop update-desktop-database ~/.local/share/applications ``` -Now, you should be all set to use CryoUtilities as normal! \ No newline at end of file +Now, you should be all set to use CryoUtilities as normal! diff --git a/internal/config.go b/internal/config.go index 88e4115..9cfa404 100644 --- a/internal/config.go +++ b/internal/config.go @@ -23,7 +23,7 @@ import ( ) // CurrentVersionNumber Version number to build with, Fyne can't support build flags just yet. -var CurrentVersionNumber = "2.2.0" +var CurrentVersionNumber = "2.2.1" // Get home Directory var HomeDirectory, _ = os.UserHomeDir() diff --git a/internal/ui_screen.go b/internal/ui_screen.go index a22f412..82b3654 100644 --- a/internal/ui_screen.go +++ b/internal/ui_screen.go @@ -16,24 +16,15 @@ package internal -/* -#cgo LDFLAGS: -lX11 -#include -*/ -import "C" import ( "fmt" + "github.com/go-gl/glfw/v3.3/glfw" "os" ) const ( - smallScreen = 1280 - mediumScreen = 1920 -) - -const ( - defaultSteamDeckScreenWidth = 1280 - defaultSteamDeckScreenHeight = 800 + smallScreenSize = 100 + mediumScreenSize = 200 ) const scaleEnvKey = "FYNE_SCALE" @@ -44,8 +35,8 @@ type ScreenSizer struct { } type screen struct { - name string - width, height int + name string + widthPhysical, heightPhysical int } func NewScreenSizer() *ScreenSizer { @@ -54,40 +45,38 @@ func NewScreenSizer() *ScreenSizer { func getDefaultScreen() screen { - display := C.XOpenDisplay(nil) - if display == nil { - CryoUtils.InfoLog.Println("Can't get info on display") - return screen{name: defaultScreenName, width: defaultSteamDeckScreenWidth, height: defaultSteamDeckScreenHeight} - } - defer C.XCloseDisplay(display) - - displayScreen := C.XDefaultScreenOfDisplay(display) - displayScreenName := C.GoString(C.XDisplayString(display)) - width := int(C.XWidthOfScreen(displayScreen)) - height := int(C.XHeightOfScreen(displayScreen)) - if width == 0 || height == 0 { - CryoUtils.InfoLog.Println("Default monitor not detected") - return screen{name: defaultScreenName, width: defaultSteamDeckScreenWidth, height: defaultSteamDeckScreenHeight} + var primaryScreen screen + + err := glfw.Init() + if err != nil { + return defaultScreen() } - return screen{displayScreenName, width, height} + defer glfw.Terminate() + + monitor := glfw.GetPrimaryMonitor() + primaryScreen.name = monitor.GetName() + primaryScreen.widthPhysical, primaryScreen.heightPhysical = monitor.GetPhysicalSize() + return primaryScreen } func (s ScreenSizer) UpdateScaleForActiveMonitor() { - defaultScreen := getDefaultScreen() - if defaultScreen.width <= smallScreen { + if s.screen.widthPhysical <= smallScreenSize { s.setScale(0.25) - } else if defaultScreen.width > smallScreen && defaultScreen.width <= mediumScreen { + } else if s.screen.widthPhysical > smallScreenSize && s.screen.widthPhysical <= mediumScreenSize { + s.setScale(0.75) + } else if s.screen.widthPhysical > mediumScreenSize { s.setScale(1) - } else if defaultScreen.width > mediumScreen { - s.setScale(2) } } func (s ScreenSizer) setScale(f float32) { err := os.Setenv(scaleEnvKey, fmt.Sprintf("%f", f)) - CryoUtils.InfoLog.Printf("Setting scale %f", f) if err != nil { CryoUtils.ErrorLog.Println(err) } } + +func defaultScreen() screen { + return screen{name: defaultScreenName, widthPhysical: 60, heightPhysical: 100} +} diff --git a/launcher.sh b/launcher.sh index dba811e..f905beb 100755 --- a/launcher.sh +++ b/launcher.sh @@ -1,6 +1,3 @@ #!/bin/bash -if [ "$(xrandr | grep ' connected' | wc -l)" -eq 1 ]; then - export FYNE_SCALE=0.25 -fi - -"$HOME"/.cryo_utilities/cryo_utilities gui +# Author: CryoByte33 and contributors to the CryoUtilities project +"$HOME/.cryo_utilities/cryo_utilities" gui