├── .github
├── funding.yml
└── workflows
│ └── release.yml
├── icon.png
├── cmd
└── cryoutilities
│ ├── Icon.png
│ └── main.go
├── launcher.sh
├── InstallCryoUtilities.desktop
├── internal
├── handler_gpu.go
├── util_test.go
├── handler_steam_api.go
├── ui_screen.go
├── ui_authentication.go
├── handler_library.go
├── ui_base.go
├── handler_cli.go
├── config.go
├── handler_swap.go
├── handler_memory.go
├── util.go
├── ui_util.go
├── ui_tab.go
├── handler_game_data.go
├── ui_window.go
└── bundled_resources.go
├── .gitignore
├── go.mod
├── uninstall.sh
├── docs
├── manual-install.md
├── faq.md
└── tweak-explanation.md
├── install.sh
├── README.md
└── LICENSE
/.github/funding.yml:
--------------------------------------------------------------------------------
1 | patreon: cryobyte33
2 | ko_fi: cryobyte33
3 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/HEAD/icon.png
--------------------------------------------------------------------------------
/cmd/cryoutilities/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/HEAD/cmd/cryoutilities/Icon.png
--------------------------------------------------------------------------------
/launcher.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Author: CryoByte33 and contributors to the CryoUtilities project
3 | "$HOME/.cryo_utilities/cryo_utilities" gui
4 |
--------------------------------------------------------------------------------
/InstallCryoUtilities.desktop:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env xdg-open
2 | [Desktop Entry]
3 | Name=Install CryoUtilities
4 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s --
5 | Icon=steamdeck-gaming-return
6 | Terminal=true
7 | Type=Application
8 | StartupNotify=false
9 |
--------------------------------------------------------------------------------
/internal/handler_gpu.go:
--------------------------------------------------------------------------------
1 | package internal
2 |
3 | import (
4 | "fmt"
5 | "os/exec"
6 | "regexp"
7 | "strconv"
8 | "strings"
9 | )
10 |
11 | // Get the current VRAM
12 | func getVRAMValue() (int, error) {
13 | cmd, err := exec.Command("glxinfo", "-B").Output()
14 |
15 | // Extract video memory
16 | re := regexp.MustCompile(`Video memory: [0-9]+`)
17 | match := re.FindStringSubmatch(string(cmd))
18 |
19 | if err != nil || match == nil {
20 | return 100, fmt.Errorf("error getting current VRAM")
21 | }
22 |
23 | output := strings.Split(match[0], " ")[2]
24 | CryoUtils.InfoLog.Println("Found a VRAM of", output)
25 | vram, _ := strconv.Atoi(output)
26 |
27 | return vram, nil
28 | }
29 |
--------------------------------------------------------------------------------
/internal/util_test.go:
--------------------------------------------------------------------------------
1 | package internal
2 |
3 | import "testing"
4 |
5 | func TestGetHumanVRAMSize(t *testing.T) {
6 | type args struct {
7 | size int
8 | }
9 | tests := []struct {
10 | name string
11 | args args
12 | want string
13 | }{
14 | {
15 | name: "Test 1",
16 | args: args{
17 | size: 256,
18 | },
19 | want: "256MB",
20 | },
21 | {
22 | name: "Test 2",
23 | args: args{
24 | size: 1024,
25 | },
26 | want: "1GB",
27 | },
28 | {
29 | name: "Test 3",
30 | args: args{
31 | size: 2048,
32 | },
33 | want: "2GB",
34 | },
35 | {
36 | name: "Test 4",
37 | args: args{
38 | size: 4096,
39 | },
40 | want: "4GB",
41 | },
42 | }
43 |
44 | for _, tt := range tests {
45 | t.Run(tt.name, func(t *testing.T) {
46 | if got := getHumanVRAMSize(tt.args.size); got != tt.want {
47 | t.Errorf("getHumanVRAMSize() = %v, want %v", got, tt.want)
48 | }
49 | })
50 | }
51 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # MacOS
2 | # General
3 | .DS_Store
4 | .AppleDouble
5 | .LSOverride
6 |
7 |
8 | # Thumbnails
9 | ._*
10 |
11 | # Files that might appear in the root of a volume
12 | .DocumentRevisions-V100
13 | .fseventsd
14 | .Spotlight-V100
15 | .TemporaryItems
16 | .Trashes
17 | .VolumeIcon.icns
18 | .com.apple.timemachine.donotpresent
19 |
20 | # Directories potentially created on remote AFP share
21 | .AppleDB
22 | .AppleDesktop
23 | Network Trash Folder
24 | Temporary Items
25 | .apdisk
26 |
27 | # Linux
28 | *~
29 |
30 | # temporary files which can be created if a process still has a handle open of a deleted file
31 | .fuse_hidden*
32 |
33 | # KDE directory preferences
34 | .directory
35 |
36 | # Linux trash folder which might appear on any partition or disk
37 | .Trash-*
38 |
39 | # .nfs files are created when an open file is removed but is still being accessed
40 | .nfs*
41 |
42 | # Windows
43 | # Windows thumbnail cache files
44 | Thumbs.db
45 | Thumbs.db:encryptable
46 | ehthumbs.db
47 | ehthumbs_vista.db
48 |
49 | # Dump file
50 | *.stackdump
51 |
52 | # Folder config file
53 | [Dd]esktop.ini
54 |
55 | # Recycle Bin used on file shares
56 | $RECYCLE.BIN/
57 |
58 | # Windows Installer files
59 | *.cab
60 | *.msi
61 | *.msix
62 | *.msm
63 | *.msp
64 |
65 | # Windows shortcuts
66 | *.lnk
67 |
68 | # Custom
69 | *.idea
70 | *.idea/*
71 | fyne-cross
72 | fyne-cross/*
73 | *.vdf
74 | /.idea/
75 | .idea
76 | .idea/*
77 | cryoutilities.log
78 | /Dockerfile
79 | /build
80 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module cryoutilities
2 |
3 | go 1.20
4 |
5 | require (
6 | fyne.io/fyne/v2 v2.3.1
7 | github.com/andygrunwald/vdf v1.1.0
8 | github.com/cristalhq/acmd v0.11.0
9 | github.com/moby/sys/mountinfo v0.6.2
10 | github.com/otiai10/copy v1.9.0
11 | golang.org/x/sys v0.5.0
12 | )
13 |
14 | require (
15 | fyne.io/systray v1.10.1-0.20230207085535-4a244dbb9d03 // indirect
16 | github.com/benoitkugler/textlayout v0.3.0 // indirect
17 | github.com/davecgh/go-spew v1.1.1 // indirect
18 | github.com/fredbi/uri v0.1.0 // indirect
19 | github.com/fsnotify/fsnotify v1.5.4 // indirect
20 | github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
21 | github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
22 | github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
23 | github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
24 | github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b // indirect
25 | github.com/go-text/typesetting v0.0.0-20221212183139-1eb938670a1f // indirect
26 | github.com/godbus/dbus/v5 v5.1.0 // indirect
27 | github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect
28 | github.com/gopherjs/gopherjs v1.17.2 // indirect
29 | github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
30 | github.com/pmezard/go-difflib v1.0.0 // indirect
31 | github.com/srwiley/oksvg v0.0.0-20220731023508-a61f04f16b76 // indirect
32 | github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
33 | github.com/stretchr/testify v1.8.0 // indirect
34 | github.com/tevino/abool v1.2.0 // indirect
35 | github.com/yuin/goldmark v1.4.0 // indirect
36 | golang.org/x/image v0.0.0-20220601225756-64ec528b34cd // indirect
37 | golang.org/x/mobile v0.0.0-20211207041440-4e6c2922fdee // indirect
38 | golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
39 | golang.org/x/text v0.3.7 // indirect
40 | gopkg.in/yaml.v3 v3.0.1 // indirect
41 | honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
42 | )
43 |
--------------------------------------------------------------------------------
/uninstall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Author: CryoByte33
3 |
4 | # This is nested for good reason, zenity won't exit the entire script if the 'x' button is pressed.
5 | # Nesting it forces execution only if an option is selected.
6 | if zenity --question --title="Disclaimer" --text="This script will uninstall CryoUtilities.\n\nDisclaimer: Do you want to proceed?" --width=600 2>/dev/null; then
7 | if zenity --question --title="Revert" --text="Do you want to revert the tweaks made by CryoUtilities?\n\nNote: This does NOT move the game data to the original location on the SSD." --width=600 2>/dev/null; then
8 | # Ask for password
9 | hasPass=$(passwd -S "$USER" | awk -F " " '{print $2}')
10 | if [[ $hasPass != "P" ]]; then
11 | zenity --error --title="Password Error" --text="Password is not set, please set one in the terminal with the passwd command, then run this again." --width=400 2>/dev/null
12 | exit 1
13 | fi
14 | PASSWD="$(zenity --password --title="Enter Password" --text="Enter Deck User Password (not Steam account!)" 2>/dev/null)"
15 | echo "$PASSWD" | sudo -v -S
16 | ans=$?
17 | if [[ $ans == 1 ]]; then
18 | zenity --error --title="Password Error" --text="Incorrect password provided, please run this command again and provide the correct password." --width=400 2>/dev/null
19 | exit 1
20 | fi
21 | # Revert everything to stock
22 | sudo bash "$HOME"/.cryo_utilities/cryo_utilities stock
23 | fi
24 | # Delete install directory
25 | rm -rf "$HOME/.cryo_utilities"
26 |
27 | # Remove Desktop icons
28 | rm -rf "$HOME"/Desktop/CryoUtilitiesUninstall.desktop 2>/dev/null
29 | rm -rf "$HOME"/Desktop/CryoUtilities.desktop 2>/dev/null
30 | rm -rf "$HOME"/Desktop/UpdateCryoUtilities.desktop 2>/dev/null
31 |
32 | # Remove Start Menu shortcuts
33 | rm -rf "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop 2>/dev/null
34 | rm -rf "$HOME"/.local/share/applications/CryoUtilities.desktop 2>/dev/null
35 | rm -rf "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop 2>/dev/null
36 | update-desktop-database ~/.local/share/applications
37 |
38 | # Remove icon from KDE
39 | xdg-icon-resource uninstall cryo-utilities 2>/dev/null
40 | fi
41 |
--------------------------------------------------------------------------------
/internal/handler_steam_api.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "encoding/json"
21 | "io"
22 | "net/http"
23 | "time"
24 | )
25 |
26 | type AppResponse struct {
27 | Applist struct {
28 | Apps []struct {
29 | Name string `json:"name"`
30 | Appid int `json:"appid"`
31 | } `json:"apps"`
32 | } `json:"applist"`
33 | }
34 |
35 | // Query the Steam API to get a JSON response object.
36 | func querySteamAPI() (AppResponse, error) {
37 | var steamResponse AppResponse
38 | client := http.Client{
39 | Timeout: time.Second * 30, // Timeout after 30 seconds
40 | }
41 |
42 | req, err := http.NewRequest(http.MethodGet, SteamApiUrl, nil)
43 | if err != nil {
44 | return steamResponse, err
45 | }
46 |
47 | req.Header.Set("User-Agent", "cryoutilities")
48 |
49 | res, err := client.Do(req)
50 | if err != nil {
51 | return steamResponse, err
52 | }
53 |
54 | if res.Body != nil {
55 | defer res.Body.Close()
56 | }
57 |
58 | body, err := io.ReadAll(res.Body)
59 | if err != nil {
60 | return steamResponse, err
61 | }
62 |
63 | err = json.Unmarshal(body, &steamResponse)
64 | if err != nil {
65 | return steamResponse, err
66 | }
67 |
68 | return steamResponse, nil
69 | }
70 |
71 | // Parse a SteamAPI response object and create a map of all games.
72 | func generateGameMap(response AppResponse) map[int]string {
73 | gameMap := map[int]string{}
74 |
75 | for i := range response.Applist.Apps {
76 | gameMap[response.Applist.Apps[i].Appid] = response.Applist.Apps[i].Name
77 | }
78 |
79 | return gameMap
80 | }
81 |
--------------------------------------------------------------------------------
/internal/ui_screen.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "fmt"
21 | "github.com/go-gl/glfw/v3.3/glfw"
22 | "os"
23 | )
24 |
25 | const (
26 | smallScreenSize = 100
27 | mediumScreenSize = 200
28 | )
29 |
30 | const scaleEnvKey = "FYNE_SCALE"
31 | const defaultScreenName = ":0"
32 |
33 | type ScreenSizer struct {
34 | screen screen
35 | }
36 |
37 | type screen struct {
38 | name string
39 | widthPhysical, heightPhysical int
40 | }
41 |
42 | func NewScreenSizer() *ScreenSizer {
43 | return &ScreenSizer{screen: getDefaultScreen()}
44 | }
45 |
46 | func getDefaultScreen() screen {
47 |
48 | var primaryScreen screen
49 |
50 | err := glfw.Init()
51 | if err != nil {
52 | return defaultScreen()
53 | }
54 | defer glfw.Terminate()
55 |
56 | monitor := glfw.GetPrimaryMonitor()
57 | primaryScreen.name = monitor.GetName()
58 | primaryScreen.widthPhysical, primaryScreen.heightPhysical = monitor.GetPhysicalSize()
59 | return primaryScreen
60 | }
61 |
62 | func (s ScreenSizer) UpdateScaleForActiveMonitor() {
63 |
64 | if s.screen.widthPhysical <= smallScreenSize {
65 | s.setScale(0.25)
66 | } else if s.screen.widthPhysical > smallScreenSize && s.screen.widthPhysical <= mediumScreenSize {
67 | s.setScale(0.75)
68 | } else if s.screen.widthPhysical > mediumScreenSize {
69 | s.setScale(1)
70 | }
71 | }
72 |
73 | func (s ScreenSizer) setScale(f float32) {
74 | err := os.Setenv(scaleEnvKey, fmt.Sprintf("%f", f))
75 | if err != nil {
76 | CryoUtils.ErrorLog.Println(err)
77 | }
78 | }
79 |
80 | func defaultScreen() screen {
81 | return screen{name: defaultScreenName, widthPhysical: 60, heightPhysical: 100}
82 | }
83 |
--------------------------------------------------------------------------------
/internal/ui_authentication.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "os/exec"
21 | "time"
22 |
23 | "fyne.io/fyne/v2/dialog"
24 | "fyne.io/fyne/v2/widget"
25 | )
26 |
27 | // Renews sudo auth for GUI mode
28 | func renewSudoAuth() {
29 | // Do a really basic command to renew sudo auth
30 | cmd := exec.Command("sudo", "-S", "--", "echo")
31 | //Sudo will exit immediately if it's the correct password, but will hang for a moment if it isn't.
32 | cmd.WaitDelay = 500 * time.Millisecond
33 | stdin, err := cmd.StdinPipe()
34 | if err != nil {
35 | CryoUtils.ErrorLog.Println(err)
36 | return
37 | }
38 | err = cmd.Start()
39 | if err != nil {
40 | CryoUtils.ErrorLog.Println(err)
41 | return
42 | }
43 | _, err = stdin.Write([]byte(CryoUtils.UserPassword + "\n"))
44 | if err != nil {
45 | cmd.Process.Kill()
46 | CryoUtils.ErrorLog.Println(err)
47 | return
48 | }
49 | stdin.Close()
50 | err = cmd.Wait()
51 | if err != nil {
52 | CryoUtils.ErrorLog.Println(err)
53 | return
54 | }
55 | }
56 |
57 | // Test that the sudo password works
58 | func testAuth(password string) error {
59 | progress := widget.NewProgressBarInfinite()
60 | d := dialog.NewCustom("Testing Authentication", "Quit", progress,
61 | CryoUtils.MainWindow,
62 | )
63 | d.Show()
64 | defer d.Hide()
65 | // Do a really basic command to renew sudo auth
66 | cmd := exec.Command("sudo", "-S", "--", "echo")
67 | //Sudo will exit immediately if it's the correct password, but will hang for a moment if it isn't.
68 | cmd.WaitDelay = 500 * time.Millisecond
69 | stdin, err := cmd.StdinPipe()
70 | if err != nil {
71 | return err
72 | }
73 | err = cmd.Start()
74 | if err != nil {
75 | return err
76 | }
77 | _, err = stdin.Write([]byte(password + "\n"))
78 | if err != nil {
79 | cmd.Process.Kill()
80 | return err
81 | }
82 | stdin.Close()
83 | err = cmd.Wait()
84 | if err != nil {
85 | return err
86 | }
87 | return nil
88 | }
89 |
--------------------------------------------------------------------------------
/internal/handler_library.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "os"
21 | "strconv"
22 | "strings"
23 |
24 | "github.com/andygrunwald/vdf"
25 | )
26 |
27 | type Library struct {
28 | Path string
29 | InstalledGames []int
30 | }
31 |
32 | func (lib *Library) listGames() {
33 | for _, game := range lib.InstalledGames {
34 | CryoUtils.InfoLog.Println(game)
35 | }
36 | }
37 |
38 | // Get a list of installed games (parseVDF), then ensure their folders in compatdata and
39 | // shaderdata get moved to the appropriate location. Then, create a symlink on the SSD.
40 | func findDataFolders() ([]Library, error) {
41 | libraries, err := parseVDF(LibraryVDFLocation)
42 | if err != nil {
43 | CryoUtils.ErrorLog.Println("Error parsing VDF at", LibraryVDFLocation)
44 | return nil, err
45 | }
46 |
47 | CryoUtils.InfoLog.Println("Loading libraries saved in VDF...")
48 | for x := range libraries {
49 | // If the library was added manually, remove the end of the path
50 | if strings.HasSuffix(libraries[x].Path, "SteamLibrary") {
51 | CryoUtils.InfoLog.Println("Found manually added library at", libraries[x].Path)
52 | libraries[x].Path = strings.ReplaceAll(libraries[x].Path, "/SteamLibrary", "")
53 | } else {
54 | CryoUtils.InfoLog.Println("Found library at", libraries[x].Path)
55 | }
56 | }
57 |
58 | return libraries, nil
59 | }
60 |
61 | // Parse the specified VDF file and return a slice of libraries.
62 | func parseVDF(file string) ([]Library, error) {
63 | var libraries []Library
64 |
65 | f, err := os.Open(file)
66 | if err != nil {
67 | return nil, err
68 | }
69 |
70 | p := vdf.NewParser(f)
71 | m, err := p.Parse()
72 | if err != nil {
73 | return nil, err
74 | }
75 |
76 | for _, library := range m["libraryfolders"].(map[string]interface{}) {
77 | var installedGames []int
78 |
79 | for game := range library.(map[string]interface{})["apps"].(map[string]interface{}) {
80 | intGame, _ := strconv.Atoi(game)
81 | installedGames = append(installedGames, intGame)
82 | }
83 | newLib := Library{
84 | Path: library.(map[string]interface{})["path"].(string),
85 | InstalledGames: installedGames,
86 | }
87 | libraries = append(libraries, newLib)
88 | }
89 | return libraries, nil
90 | }
91 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Main
2 |
3 | on: push
4 |
5 | env:
6 | release_name: 2.0-${{github.run_number}}
7 |
8 | jobs:
9 | build:
10 | runs-on: ubuntu-22.04
11 | steps:
12 | - name: Checkout
13 | uses: actions/checkout@v3
14 |
15 | - uses: awalsh128/cache-apt-pkgs-action@latest
16 | with:
17 | packages: golang gcc libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev
18 | version: 1.0
19 |
20 | - name: Setup Go
21 | uses: actions/setup-go@v3
22 | with:
23 | go-version: '^1.21.x'
24 | check-latest: true
25 | cache: true
26 |
27 | - name: Install Go Packages
28 | run: |
29 | go mod tidy
30 |
31 | - name: Build
32 | run: GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o cryo_utilities ./cmd/cryoutilities
33 |
34 | - name: Upload Artifact
35 | uses: actions/upload-artifact@v3
36 | with:
37 | name: ${{env.release_name}}
38 | path: cryo_utilities
39 |
40 | main-release:
41 | needs: build
42 | runs-on: ubuntu-latest
43 | if: github.ref == 'refs/heads/main'
44 | steps:
45 | - name: Checkout
46 | uses: actions/checkout@v3
47 |
48 | - name: Download Artifact
49 | uses: actions/download-artifact@v3
50 | id: download
51 | with:
52 | name: ${{env.release_name}}
53 |
54 | - name: Install Hub Package
55 | run: sudo apt-get install -y hub
56 |
57 | - name: Generate Checksum
58 | run: md5sum cryo_utilities > cu.md5
59 |
60 | - name: Delete Previous Latest Release
61 | uses: dev-drprasad/delete-tag-and-release@v0.2.1
62 | with:
63 | tag_name: latest
64 | delete_release: true
65 | repo: ${{ github.repository }}
66 | env:
67 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68 |
69 | - name: Create Unique Release
70 | shell: bash
71 | run: hub release create ${{ env.release_name }} -m ${{ env.release_name }} -a cryo_utilities -a cu.md5
72 | env:
73 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74 |
75 | - name: Create Latest Release
76 | shell: bash
77 | run: hub release create latest -m latest -a cryo_utilities -a cu.md5
78 | env:
79 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80 |
81 | dev-release:
82 | needs: build
83 | runs-on: ubuntu-latest
84 | if: github.ref == 'refs/heads/develop'
85 | steps:
86 | - name: Checkout
87 | uses: actions/checkout@v3
88 |
89 | - name: Download Artifact
90 | uses: actions/download-artifact@v3
91 | id: download
92 | with:
93 | name: ${{env.release_name}}
94 |
95 | - name: Install Hub Package
96 | run: sudo apt-get install -y hub
97 |
98 | - name: Delete Previous Develop Release
99 | uses: dev-drprasad/delete-tag-and-release@v0.2.1
100 | with:
101 | tag_name: develop
102 | delete_release: true
103 | repo: ${{ github.repository }}
104 | env:
105 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106 |
107 | - name: Create Develop Release
108 | shell: bash
109 | run: hub release create develop -m develop -a cryo_utilities
110 | env:
111 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112 |
--------------------------------------------------------------------------------
/docs/manual-install.md:
--------------------------------------------------------------------------------
1 | # Manual Installation
2 |
3 | 1. Open Konsole and use the following commands, pressing the Enter/Return key after each:
4 | ```bash
5 | cd
6 | mkdir .cryo_utilities
7 | cd .cryo_utilities
8 | ```
9 | 2. Go to [the releases page](https://github.com/CryoByte33/steam-deck-utilities/releases/tag/latest) and download cryo_utilities.
10 | 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.
11 | 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`.
12 | 5. Move all 3 downloaded files to `/home/deck/.cryo_utilities`.
13 | 6. Open Konsole and paste the entire block below, then press Enter/Return:
14 | ```bash
15 | cd ~/.cryo_utilities
16 | chmod +x cryo_utilities
17 | chmod +x launcher.sh
18 | xdg-icon-resource install cryo-utilities.png --size 64
19 | rm -rf "$HOME"/Desktop/CryoUtilitiesUninstall.desktop 2>/dev/null
20 | echo '#!/usr/bin/env xdg-open
21 | [Desktop Entry]
22 | Name=Uninstall CryoUtilities
23 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/uninstall.sh | bash -s --
24 | Icon=delete
25 | Terminal=false
26 | Type=Application
27 | StartupNotify=false' >"$HOME"/Desktop/CryoUtilitiesUninstall.desktop
28 | chmod +x "$HOME"/Desktop/CryoUtilitiesUninstall.desktop
29 | rm -rf "$HOME"/Desktop/CryoUtilities.desktop 2>/dev/null
30 | echo '#!/usr/bin/env xdg-open
31 | [Desktop Entry]
32 | Name=CryoUtilities
33 | Exec=bash $HOME/.cryo_utilities/launcher.sh
34 | Icon=cryo-utilities
35 | Terminal=false
36 | Type=Application
37 | StartupNotify=false' >"$HOME"/Desktop/CryoUtilities.desktop
38 | chmod +x "$HOME"/Desktop/CryoUtilities.desktop
39 | rm -rf "$HOME"/Desktop/UpdateCryoUtilities.desktop 2>/dev/null
40 | mkdir -p "$HOME"/.local/share/applications
41 | echo '#!/usr/bin/env xdg-open
42 | [Desktop Entry]
43 | Name=Update CryoUtilities
44 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s --
45 | Icon=bittorrent-sync
46 | Terminal=false
47 | Type=Application
48 | StartupNotify=false' >"$HOME"/Desktop/UpdateCryoUtilities.desktop
49 | chmod +x "$HOME"/Desktop/UpdateCryoUtilities.desktop
50 | rm -rf "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop 2>/dev/null
51 | echo '#!/usr/bin/env xdg-open
52 | [Desktop Entry]
53 | Name=CryoUtilities - Uninstall
54 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/uninstall.sh | bash -s --
55 | Icon=delete
56 | Terminal=false
57 | Type=Application
58 | Categories=Utility
59 | StartupNotify=false' >"$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop
60 | chmod +x "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop
61 | rm -rf "$HOME"/.local/share/applications/CryoUtilities.desktop 2>/dev/null
62 | echo '#!/usr/bin/env xdg-open
63 | [Desktop Entry]
64 | Name=CryoUtilities
65 | Exec=bash $HOME/.cryo_utilities/launcher.sh
66 | Icon=cryo-utilities
67 | Terminal=false
68 | Type=Application
69 | Categories=Utility
70 | StartupNotify=false' >"$HOME"/.local/share/applications/CryoUtilities.desktop
71 | chmod +x "$HOME"/.local/share/applications/CryoUtilities.desktop
72 | rm -rf "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop 2>/dev/null
73 | echo '#!/usr/bin/env xdg-open
74 | [Desktop Entry]
75 | Name=CryoUtilities - Update
76 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s --
77 | Icon=bittorrent-sync
78 | Terminal=false
79 | Type=Application
80 | Categories=Utility
81 | StartupNotify=false' >"$HOME"/.local/share/applications/UpdateCryoUtilities.desktop
82 | chmod +x "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop
83 | update-desktop-database ~/.local/share/applications
84 | ```
85 | Now, you should be all set to use CryoUtilities as normal!
86 |
--------------------------------------------------------------------------------
/docs/faq.md:
--------------------------------------------------------------------------------
1 | # Frequently Asked Questions
2 | ## General
3 | ### Who are you?
4 | Hey, I'm CryoByte33, or Kyle. I run a [YouTube channel](https://youtube.com/@cryobyte33) that uses my 18 years of Linux
5 | experience, and experience as a DevOps Engineer for my day job to help people play the games they love on their Decks!
6 |
7 | ### Will this destroy my Steam Deck?
8 | I haven't heard an instance of this happening, but if something happens **_PLEASE_** open an issue here.
9 |
10 | ### Does this work on Windows?
11 | Unfortunately, no. Windows doesn't allow tuning things this close to the kernel, with the exception of page file size,
12 | which is configurable through a GUI inside Windows.
13 |
14 | ### Do these fixes affect battery life or increase heat generated by the Deck?
15 | No, this doesn't directly affect either the fan speeds or battery life, _but_ it could lift a bottleneck and allow the
16 | CPU and GPU to work harder, thus raising fan speeds or lowering battery life by technicality.
17 |
18 | ### Are there any downsides to these fixes?
19 | Not that I'm aware of. At worst, performance breaks even.
20 |
21 | ### Will updates revert these fixes/settings?
22 | No, but reformatting the Deck will revert it. I tested with several updates and all tweaks were left in place. In the
23 | event that an update does revert some settings, I will do my best to update the community about it and give you steps
24 | if necessary.
25 |
26 | ### What does X setting do?
27 | Please check out my [video on YouTube](https://www.youtube.com/watch?v=od9_a1QQQns) to get an explanation of everything!
28 |
29 | ## Swap/Swappiness
30 | ### What games benefit from the larger swap file?
31 | Any game that uses a combined 16GB for RAM and VRAM will likely benefit from the swap fix in some way. How much the swap
32 | fix helps will depend on a few factors including asset compression, asset size, and churn of data in memory.
33 |
34 | ### Do the swap changes work for all games?
35 | Yes, they work for any program on SteamOS loaded from **any** location. That means that even Google Chrome installed on
36 | an external hard drive would benefit from these changes (If the trigger conditions are met).
37 |
38 | ### Are there any situations where the swap fix isn't a good option?
39 | No, as long as swappiness is also tuned properly.
40 |
41 | ### Does the swap fix hurt emulators?
42 | No, even Yuzu and Cemu have benefited from these fixes, and I hope to test more emulators soon.
43 |
44 | ### Will the swap fix hurt my SSD?
45 | No, using a lower swappiness will completely offset the additional writes from a larger swap file, and actually keep
46 | the SSD healthier for longer.
47 |
48 | ### How much SSD wear does the stock configuration cause?
49 | In general, a swappiness of 100 will try to put data into swap prior to RAM. Because of that, a large percentage of all
50 | memory operations would wear your SSD. I don't have a spare SSD to test this, but I would guess that the default wear
51 | pattern would reduce the SSD's life to about 4 years of average gameplay on modern games.
52 |
53 | Setting the swappiness to 1 won't quite prevent data from making it into swap at all times, but it will reduce the
54 | frequency to only when the Deck overflows its total memory.
55 |
56 | ### Do differently-sized SSDs have a performance difference for swapping?
57 | Yes, the read and write speeds both make a difference in the speed of swapping, and therefore performance. That said,
58 | Valve did a pretty good job at choosing good quality parts with relatively similar speeds so we'd all have a consistent
59 | experience.
60 |
61 | In general, the larger the SSD the faster it is, but there's a lot more to it than that. I plan to test the difference
62 | in speeds as soon as possible.
63 |
64 | ## Memory Tuning
65 | ### What performance differences can I expect from these tweaks?
66 | In general, you'll likely see much smoother gameplay. FPS averages may also be boosted in games where the CPU is the
67 | major bottleneck.
68 |
69 | ### Is there any risk to applying these settings?
70 | Not as far as I'm aware, since all of these are built into the Linux kernel and I'm just changing pre-existing values
71 | rather than adding or changing functionality.
72 |
--------------------------------------------------------------------------------
/internal/ui_base.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "errors"
21 |
22 | "fyne.io/fyne/v2"
23 | "fyne.io/fyne/v2/app"
24 | "fyne.io/fyne/v2/container"
25 | "fyne.io/fyne/v2/dialog"
26 | "fyne.io/fyne/v2/theme"
27 | "fyne.io/fyne/v2/widget"
28 | )
29 |
30 | func InitUI() {
31 | // Create a Fyne application
32 | screenSizer := NewScreenSizer()
33 | screenSizer.UpdateScaleForActiveMonitor()
34 | fyneApp := app.NewWithID("io.cryobyte.cryoutilities")
35 | CryoUtils.App = fyneApp
36 | CryoUtils.App.SetIcon(ResourceIconPng)
37 |
38 | // Show and run the app
39 | title := "CryoUtilities " + CurrentVersionNumber
40 | CryoUtils.MainWindow = fyneApp.NewWindow(title)
41 | CryoUtils.makeUI()
42 | CryoUtils.MainWindow.CenterOnScreen()
43 | CryoUtils.MainWindow.ShowAndRun()
44 | }
45 |
46 | func (app *Config) makeUI() {
47 | app.authUI()
48 |
49 | // Show a disclaimer that I'm not responsible for damage.
50 | dialog.ShowConfirm("Disclaimer",
51 | "This script was made by CryoByte33 to resize the swapfile on a Steam Deck.\n\n"+
52 | "Disclaimer: I am in no way responsible to damage done to any\n"+
53 | "device this is executed on, all liability lies with the user.\n\n"+
54 | "Do you accept these terms?",
55 | func(b bool) {
56 | if !b {
57 | presentErrorInUI(errors.New("terms not accepted"), CryoUtils.MainWindow)
58 | CryoUtils.MainWindow.Close()
59 | } else {
60 | CryoUtils.InfoLog.Println("Terms accepted, continuing...")
61 | }
62 | },
63 | CryoUtils.MainWindow,
64 | )
65 |
66 | // Create and size a Fyne window
67 | CryoUtils.MainWindow.Resize(fyne.NewSize(700, 410))
68 | CryoUtils.MainWindow.SetFixedSize(true)
69 | CryoUtils.MainWindow.SetMaster()
70 | }
71 |
72 | func (app *Config) mainUI() {
73 | // Create heading section
74 | tabs := container.NewAppTabs(
75 | container.NewTabItemWithIcon("Home", theme.HomeIcon(), app.homeTab()),
76 | container.NewTabItemWithIcon("Swap", theme.MailReplyAllIcon(), app.swapTab()),
77 | container.NewTabItemWithIcon("Memory", theme.ComputerIcon(), app.memoryTab()),
78 | container.NewTabItemWithIcon("Storage", theme.StorageIcon(), app.storageTab()),
79 | container.NewTabItemWithIcon("VRAM", theme.ViewFullScreenIcon(), app.vramTab()),
80 | )
81 | tabs.SetTabLocation(container.TabLocationTop)
82 |
83 | finalContent := container.NewVBox(tabs)
84 | app.MainWindow.SetContent(finalContent)
85 | }
86 |
87 | func (app *Config) authUI() {
88 | // Refactor this, duplicated code.
89 | passwordEntry := widget.NewPasswordEntry()
90 | passwordEntry.OnSubmitted = func(s string) {
91 | CryoUtils.InfoLog.Println("Testing password...")
92 | err := testAuth(s)
93 | if err != nil {
94 | CryoUtils.InfoLog.Println("Password invalid, asking again...")
95 | dialog.ShowInformation("Incorrect password", "Incorrect password, please try again.",
96 | CryoUtils.MainWindow)
97 | } else {
98 | CryoUtils.InfoLog.Println("Password valid, continuing...")
99 | CryoUtils.UserPassword = s
100 | app.mainUI()
101 | }
102 | }
103 | passwordButton := widget.NewButton("Submit", func() {
104 | CryoUtils.InfoLog.Println("Testing password...")
105 | err := testAuth(passwordEntry.Text)
106 | if err != nil {
107 | CryoUtils.InfoLog.Println("Password invalid, asking again...")
108 | dialog.ShowInformation("Incorrect password", "Incorrect password, please try again.",
109 | CryoUtils.MainWindow)
110 | } else {
111 | CryoUtils.InfoLog.Println("Password valid, continuing...")
112 | CryoUtils.UserPassword = passwordEntry.Text
113 | app.mainUI()
114 | }
115 | })
116 | passwordVBox := container.NewVBox(passwordEntry, passwordButton)
117 | passwordContainer := widget.NewCard("Enter your sudo/deck password.", "Enter your sudo/deck password.", passwordVBox)
118 |
119 | // Add container to window
120 |
121 | app.MainWindow.SetContent(passwordContainer)
122 | }
123 |
--------------------------------------------------------------------------------
/internal/handler_cli.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "strconv"
21 | "strings"
22 | )
23 |
24 | // ChangeSwapSizeCLI Change the swap file size to the specified size in GB
25 | func ChangeSwapSizeCLI(size int, isUI bool) error {
26 | // Refresh creds if running with UI
27 | if isUI {
28 | renewSudoAuth()
29 | }
30 | // Disable swap temporarily
31 | err := disableSwap()
32 | if err != nil {
33 | return err
34 | }
35 |
36 | // Resize the file
37 | err = resizeSwapFile(size)
38 | if err != nil {
39 | return err
40 | }
41 |
42 | // Refresh creds if running with UI
43 | // Prevents long-running swap resized from causing issues
44 | if isUI {
45 | renewSudoAuth()
46 | }
47 | // Set permissions on file
48 | err = setSwapPermissions()
49 | if err != nil {
50 | return err
51 | }
52 |
53 | // Initialize new swap file
54 | err = initNewSwapFile()
55 | if err != nil {
56 | return err
57 | }
58 | return nil
59 | }
60 |
61 | func UseRecommendedSettings() error {
62 | // Change swap
63 | CryoUtils.InfoLog.Println("Starting swap file resize...")
64 | availableSpace, err := getFreeSpace("/home")
65 | if err != nil {
66 | return err
67 | }
68 | if availableSpace < RecommendedSwapSizeBytes {
69 | size := 1
70 | var availableSizes []string
71 | availableSizes, err = getAvailableSwapSizes()
72 | if err != nil {
73 | return err
74 | }
75 | if len(availableSizes) != 1 {
76 | // Get the last entry in the availableSizes list
77 | size, err = strconv.Atoi(strings.Fields(availableSizes[len(availableSizes)-1])[0])
78 | if err != nil {
79 | return err
80 | }
81 | // Never create a swap file larger than 16GB automatically.
82 | if size > 16 {
83 | size = 16
84 | }
85 | }
86 | err = ChangeSwapSizeCLI(size, true)
87 | if err != nil {
88 | return err
89 | }
90 | } else {
91 | err = ChangeSwapSizeCLI(RecommendedSwapSize, true)
92 | if err != nil {
93 | return err
94 | }
95 | }
96 | CryoUtils.InfoLog.Println("Swap file resized, changing swappiness...")
97 | err = ChangeSwappiness(RecommendedSwappiness)
98 | if err != nil {
99 | return err
100 | }
101 |
102 | CryoUtils.InfoLog.Println("Swappiness changed, enabling HugePages...")
103 | err = SetHugePages()
104 | if err != nil {
105 | return err
106 | }
107 |
108 | CryoUtils.InfoLog.Println("HugePages enabled, setting compaction proactiveness...")
109 | err = SetCompactionProactiveness()
110 | if err != nil {
111 | return err
112 | }
113 |
114 | CryoUtils.InfoLog.Println("Compaction proactiveness changed, disabling hugePage defragmentation...")
115 | err = SetDefrag()
116 | if err != nil {
117 | return err
118 | }
119 |
120 | CryoUtils.InfoLog.Println("HugePage defragmentation disabled, setting page lock unfairness...")
121 | err = SetPageLockUnfairness()
122 | if err != nil {
123 | return err
124 | }
125 |
126 | CryoUtils.InfoLog.Println("Page lock unfairness changed, enabling Shared Memory...")
127 | err = SetShMem()
128 | if err != nil {
129 | return err
130 | }
131 |
132 | CryoUtils.InfoLog.Println("All settings configured!")
133 | return nil
134 | }
135 |
136 | func UseStockSettings() error {
137 | CryoUtils.InfoLog.Println("Resizing swap file to 1GB...")
138 | // Revert swap file size
139 | err := ChangeSwapSizeCLI(DefaultSwapSize, true)
140 | if err != nil {
141 | return err
142 | }
143 |
144 | CryoUtils.InfoLog.Println("Setting swappiness to 100...")
145 | // Revert swappiness
146 | err = ChangeSwappiness(DefaultSwappiness)
147 | if err != nil {
148 | return err
149 | }
150 |
151 | CryoUtils.InfoLog.Println("Disabling HugePages...")
152 | // Enable HugePages
153 | err = RevertHugePages()
154 | if err != nil {
155 | return err
156 | }
157 |
158 | CryoUtils.InfoLog.Println("Reverting compaction proactiveness...")
159 | err = RevertCompactionProactiveness()
160 | if err != nil {
161 | return err
162 | }
163 |
164 | CryoUtils.InfoLog.Println("Enabling hugePage defragmentation...")
165 | err = RevertDefrag()
166 | if err != nil {
167 | return err
168 | }
169 |
170 | CryoUtils.InfoLog.Println("Reverting page lock unfairness...")
171 | err = RevertPageLockUnfairness()
172 | if err != nil {
173 | return err
174 | }
175 |
176 | CryoUtils.InfoLog.Println("Disabling shared memory in hugepages...")
177 | err = RevertShMem()
178 | if err != nil {
179 | CryoUtils.InfoLog.Println("All settings reverted to default!")
180 | }
181 |
182 | return nil
183 | }
184 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Author: CryoByte33
3 |
4 | # Create a hidden directory for the script, if not present
5 | mkdir -p "$HOME/.cryo_utilities" &>/dev/null
6 | cd "$HOME/.cryo_utilities" || exit 1
7 |
8 | # Download checksum to compare with local binary, if present
9 | wget https://github.com/CryoByte33/steam-deck-utilities/releases/download/latest/cu.md5 -O "$HOME/.cryo_utilities/cu.md5" 2>&1
10 | sleep 1
11 | if md5sum -c --quiet cu.md5; then
12 | zenity --info --text="No update necessary!" --width=300
13 | exit 0
14 | fi
15 |
16 | # Uninstall swap resizer if present
17 | # Delete legacy install directory
18 | rm -rf "$HOME/.swap_resizer" &>/dev/null
19 |
20 | # Remove legacy Desktop icons
21 | rm -rf ~/Desktop/SwapResizerUninstall.desktop &>/dev/null
22 | rm -rf ~/Desktop/SwapResizer.desktop &>/dev/null
23 |
24 | # Remove old binary
25 | rm -f "$HOME/.cryo_utilities/cryo_utilities" &>/dev/null
26 |
27 | # Attempt to download the binary 3 times.
28 | for i in {1..3}; do
29 | # Download binary
30 | wget https://github.com/CryoByte33/steam-deck-utilities/releases/download/latest/cryo_utilities -O "$HOME/.cryo_utilities/cryo_utilities" 2>&1 | sed -u 's/.* \([0-9]\+%\)\ \+\([0-9.]\+.\) \(.*\)/\1\n# Downloading at \2\/s, ETA \3/' | zenity --progress --title="Downloading CU Binary, attempt $i of 3..." --auto-close --width=500
31 |
32 | # Start a loop testing if zenity is running, and if not kill wget (allows for cancel to work)
33 | RUNNING=0
34 | while [ $RUNNING -eq 0 ]; do
35 | if [ -z "$(pidof zenity)" ]; then
36 | pkill wget
37 | RUNNING=1
38 | fi
39 | sleep 0.1
40 | done
41 |
42 | sleep 1
43 | # Compare checksum to new binary
44 | if md5sum -c --quiet cu.md5; then
45 | break 2
46 | fi
47 |
48 | if [ "$i" -ge "3" ]; then
49 | zenity --error --text="Install/upgrade of CryoUtilities has failed!\n\nBinary couldn't be downloaded correctly, this may be a network or GitHub issue." --width=500
50 | exit 1
51 | fi
52 | done
53 |
54 | chmod +x "$HOME/.cryo_utilities/cryo_utilities"
55 | rm -f cu.md5 &>/dev/null
56 |
57 | # Remove old launcher
58 | rm -f "$HOME/.cryo_utilities/launcher.sh" &>/dev/null
59 |
60 | # Install launcher script
61 | wget https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/launcher.sh -O "$HOME/.cryo_utilities/launcher.sh"
62 | chmod +x "$HOME/.cryo_utilities/launcher.sh"
63 |
64 | # Remove old icon
65 | rm -f "$HOME/.cryo_utilities/cryo-utilities.png" &>/dev/null
66 |
67 | # Install Icon
68 | wget https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/cmd/cryoutilities/Icon.png -O "$HOME/.cryo_utilities/cryo-utilities.png"
69 | xdg-icon-resource install cryo-utilities.png --size 64
70 |
71 | # Create Desktop icons
72 | rm -rf "$HOME"/Desktop/CryoUtilitiesUninstall.desktop 2>/dev/null
73 | echo '#!/usr/bin/env xdg-open
74 | [Desktop Entry]
75 | Name=Uninstall CryoUtilities
76 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/uninstall.sh | bash -s --
77 | Icon=delete
78 | Terminal=false
79 | Type=Application
80 | StartupNotify=false' >"$HOME"/Desktop/CryoUtilitiesUninstall.desktop
81 | chmod +x "$HOME"/Desktop/CryoUtilitiesUninstall.desktop
82 |
83 | rm -rf "$HOME"/Desktop/CryoUtilities.desktop 2>/dev/null
84 | echo "#!/usr/bin/env xdg-open
85 | [Desktop Entry]
86 | Name=CryoUtilities
87 | Exec=bash $HOME/.cryo_utilities/launcher.sh
88 | Icon=cryo-utilities
89 | Terminal=false
90 | Type=Application
91 | StartupNotify=false" >"$HOME"/Desktop/CryoUtilities.desktop
92 | chmod +x "$HOME"/Desktop/CryoUtilities.desktop
93 |
94 | rm -rf "$HOME"/Desktop/UpdateCryoUtilities.desktop 2>/dev/null
95 | echo "#!/usr/bin/env xdg-open
96 | [Desktop Entry]
97 | Name=Update CryoUtilities
98 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s --
99 | Icon=bittorrent-sync
100 | Terminal=false
101 | Type=Application
102 | StartupNotify=false" >"$HOME"/Desktop/UpdateCryoUtilities.desktop
103 | chmod +x "$HOME"/Desktop/UpdateCryoUtilities.desktop
104 |
105 | # Create Start Menu Icons
106 | rm -rf "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop 2>/dev/null
107 | echo "#!/usr/bin/env xdg-open
108 | [Desktop Entry]
109 | Name=CryoUtilities - Uninstall
110 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/uninstall.sh | bash -s --
111 | Icon=delete
112 | Terminal=false
113 | Type=Application
114 | Categories=Utility
115 | StartupNotify=false" >"$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop
116 | chmod +x "$HOME"/.local/share/applications/CryoUtilitiesUninstall.desktop
117 |
118 | rm -rf "$HOME"/.local/share/applications/CryoUtilities.desktop 2>/dev/null
119 | echo "#!/usr/bin/env xdg-open
120 | [Desktop Entry]
121 | Name=CryoUtilities
122 | Exec=bash $HOME/.cryo_utilities/launcher.sh
123 | Icon=cryo-utilities
124 | Terminal=false
125 | Type=Application
126 | Categories=Utility
127 | StartupNotify=false" >"$HOME"/.local/share/applications/CryoUtilities.desktop
128 | chmod +x "$HOME"/.local/share/applications/CryoUtilities.desktop
129 |
130 | rm -rf "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop 2>/dev/null
131 | echo "#!/usr/bin/env xdg-open
132 | [Desktop Entry]
133 | Name=CryoUtilities - Update
134 | Exec=curl https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/install.sh | bash -s --
135 | Icon=bittorrent-sync
136 | Terminal=false
137 | Type=Application
138 | Categories=Utility
139 | StartupNotify=false" >"$HOME"/.local/share/applications/UpdateCryoUtilities.desktop
140 | chmod +x "$HOME"/.local/share/applications/UpdateCryoUtilities.desktop
141 |
142 | update-desktop-database ~/.local/share/applications
143 |
144 | zenity --info --text="Install/upgrade of CryoUtilities has been completed!" --width=300
145 |
--------------------------------------------------------------------------------
/internal/config.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "image/color"
21 | "os"
22 | "path/filepath"
23 | )
24 |
25 | // CurrentVersionNumber Version number to build with, Fyne can't support build flags just yet.
26 | var CurrentVersionNumber = "2.2.2"
27 |
28 | // Get home Directory
29 | var HomeDirectory, _ = os.UserHomeDir()
30 |
31 | // InstallDirectory Location the program is installed.
32 | var InstallDirectory = filepath.Join(HomeDirectory, ".cryo_utilities")
33 |
34 | // LogFilePath Location of the log file
35 | var LogFilePath = filepath.Join(InstallDirectory, "cryoutilities.log")
36 |
37 | //////////////////////////
38 | // Recommended Settings //
39 | //////////////////////////
40 |
41 | var RecommendedSwapSize = 16
42 | var RecommendedSwapSizeBytes = int64(RecommendedSwapSize * GigabyteMultiplier)
43 | var RecommendedSwappiness = "1"
44 | var RecommendedHugePages = "always"
45 | var RecommendedCompactionProactiveness = "0"
46 | var RecommendedHugePageDefrag = "0"
47 | var RecommendedPageLockUnfairness = "1"
48 | var RecommendedShMem = "advise"
49 | var RecommendedVRAM = 4096
50 |
51 | //////////////////////
52 | // Default Settings //
53 | //////////////////////
54 |
55 | var DefaultSwapFileLocation = "/home/swapfile"
56 | var DefaultSwapSize = 1
57 | var DefaultSwapSizeBytes = int64(DefaultSwapSize * GigabyteMultiplier)
58 | var DefaultSwappiness = "60"
59 | var DefaultHugePages = "madvise"
60 | var DefaultCompactionProactiveness = "20"
61 | var DefaultHugePageDefrag = "1"
62 | var DefaultPageLockUnfairness = "5"
63 | var DefaultShMem = "never"
64 |
65 | ////////////////
66 | // Unit Files //
67 | ////////////////
68 |
69 | var TmpFilesRoot = "/etc/tmpfiles.d"
70 |
71 | var TemplateUnitFile = "# Path Mode UID GID Age Argument\nw PARAM - - - - VALUE"
72 |
73 | var UnitMatrix = map[string]string{
74 | "swappiness": "/proc/sys/vm/swappiness",
75 | "page_lock_unfairness": "/proc/sys/vm/page_lock_unfairness",
76 | "compaction_proactiveness": "/proc/sys/vm/compaction_proactiveness",
77 | "hugepages": "/sys/kernel/mm/transparent_hugepage/enabled",
78 | "shmem_enabled": "/sys/kernel/mm/transparent_hugepage/shmem_enabled",
79 | "defrag": "/sys/kernel/mm/transparent_hugepage/khugepaged/defrag",
80 | }
81 |
82 | var OldSwappinessUnitFile = "/etc/sysctl.d/zzz-custom-swappiness.conf"
83 | var NHPTestingFile = "/proc/sys/vm/nr_hugepages"
84 |
85 | /////////////////
86 | // UI Settings //
87 | /////////////////
88 |
89 | // HeaderTextSize Header Text Size
90 | var HeaderTextSize = float32(32)
91 |
92 | // SubHeadingTextSize Subheader Text Size
93 | var SubHeadingTextSize = float32(16)
94 |
95 | // Green UI Color
96 | var Green = color.RGBA{R: 0, G: 155, B: 0, A: 255}
97 |
98 | // Gray UI Color
99 | var Gray = color.RGBA{R: 155, G: 155, B: 155, A: 255}
100 |
101 | // Red UI Color
102 | var Red = color.RGBA{R: 255, G: 0, B: 0, A: 255}
103 |
104 | // White UI Color
105 | var White = color.RGBA{R: 255, G: 255, B: 255, A: 255}
106 |
107 | //////////////////////////////////
108 | // Swap and swappiness settings //
109 | //////////////////////////////////
110 |
111 | // AvailableSwapSizes A list of swap sizes available to choose from, in GB
112 | var AvailableSwapSizes = []string{"2", "4", "6", "8", "12", "16", "20", "24", "32"}
113 |
114 | // AvailableSwappinessOptions A list of swappiness options to choose from, valid range 0-200
115 | var AvailableSwappinessOptions = []string{"0", "1", "10", "25", "50", "60", "75", "90", "100 (Default)", "150", "200"}
116 |
117 | // SpaceOverhead The amount of space to keep available above the swapfile size, should prevent boot loops
118 | var SpaceOverhead = 1 * GigabyteMultiplier // 1GB
119 |
120 | // GigabyteMultiplier Used to convert gigabytes to bytes
121 | var GigabyteMultiplier = 1024 * 1024 * 1024
122 |
123 | ////////////////////////
124 | // Game Data settings //
125 | ////////////////////////
126 |
127 | // LibraryVDFLocation The default location of Steam's library VDF
128 | var LibraryVDFLocation = filepath.Join(HomeDirectory, ".steam/steam/steamapps/libraryfolders.vdf")
129 |
130 | // MountDirectory The folder where all external devices are mounts
131 | var MountDirectory = "/run/media"
132 |
133 | // SteamDataRoot The default location where Steam keeps compatdata and shadercache
134 | var SteamDataRoot = filepath.Join(HomeDirectory, ".local/share/Steam")
135 |
136 | // SteamCompatRoot Generates the full path of the compatdata folder, on SSD
137 | var SteamCompatRoot = filepath.Join(SteamDataRoot, "steamapps/compatdata")
138 |
139 | // SteamShaderRoot Generates the full path of the shadercache folder, on SSD
140 | var SteamShaderRoot = filepath.Join(SteamDataRoot, "steamapps/shadercache")
141 |
142 | // ExternalDataRoot The location where I'll keep compatdata and shadercache on microSD cards
143 | var ExternalDataRoot = "cryoutilities_steam_data"
144 |
145 | // ExternalCompatRoot Generates the full path of the compatdata folder, on microSD
146 | var ExternalCompatRoot = filepath.Join(ExternalDataRoot, "compatdata")
147 |
148 | // ExternalShaderRoot Generates the full path of the shadercache folder, on microSD
149 | var ExternalShaderRoot = filepath.Join(ExternalDataRoot, "shadercache")
150 |
151 | // SteamApiUrl The URL for the Steam GetAppList URL
152 | var SteamApiUrl = "https://api.steampowered.com/ISteamApps/GetAppList/v0002/"
153 |
154 | // SteamGameMaxInteger Anything over this number is presumed to be a Proton version
155 | // Prevents accidental removal of Proton files
156 | var SteamGameMaxInteger = 1000000000
157 |
--------------------------------------------------------------------------------
/docs/tweak-explanation.md:
--------------------------------------------------------------------------------
1 | # Tweak Explanation
2 |
3 | ## Swap Size
4 |
5 | ### What It Is
6 |
7 | As per the [Arch Wiki](https://wiki.archlinux.org/title/swap):
8 |
9 | ```
10 | Linux divides its physical RAM (random access memory) into chunks of memory called pages. Swapping is the process
11 | whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that
12 | page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.
13 | ```
14 |
15 | ### Why Did I Change It?
16 |
17 | By increasing the swap size, we can do a few things:
18 |
19 | * Significantly reduce memory pressure
20 | * This allows more to be cached while simultaneously allowing for VRAM to inflate a bit more
21 | * Have a stash of "emergency memory" in case physical memory runs low
22 | * This prevents bulk evictions and distributes memory management across a longer period of time, preventing latency
23 | spikes
24 |
25 | ### How It's Done
26 |
27 | ```bash
28 | sudo swapoff -a
29 | sudo dd if=/dev/zero of=/home/swapfile bs=1G count=SIZE_IN_GB status=none
30 | sudo chmod 0600 /home/swapfile
31 | sudo mkswap /home/swapfile
32 | sudo swapon /home/swapfile
33 | ```
34 |
35 | ## Swappiness
36 |
37 | ### What It Does
38 |
39 | Also from the [Arch Wiki](https://wiki.archlinux.org/title/swap#Swappiness):
40 |
41 | > The swappiness sysctl parameter represents the kernel's preference (or avoidance) of swap space. Swappiness can have
42 | > a value between 0 and 200 (max 100 if Linux < 5.8), the default value is 60. A low value causes the kernel to avoid
43 | > swapping, a high value causes the kernel to try to use swap space, and a value of 100 means IO cost is assumed to be
44 | > equal. Using a low value on sufficient memory is known to improve responsiveness on many systems.
45 |
46 | ### Why Did I Change It?
47 |
48 | By default, the Deck has a very high swappiness of 100, which can lead to data going to swap when there's a lot of
49 | physical memory left.
50 |
51 | This can can be bad for two reasons:
52 |
53 | * Excessive writes can shorten the life of your drive
54 | * Swap is much slower than memory, and using it slows things down
55 |
56 | So, by reducing swap to a lower value, or my recommended value of 1, we can:
57 |
58 | 1. Ensure that swap is only used at the very last second, when it's really needed
59 | 2. Preserve drive health
60 |
61 | ### How It's Done
62 |
63 | ```bash
64 | echo VALUE | sudo tee /proc/sys/vm/swappiness
65 | ```
66 |
67 | ## Transparent Hugepages
68 |
69 | ### What It Does
70 |
71 | From an [excellent writeup by Emin here](https://xeome.github.io/notes/Transparent-Huge-Pages/):
72 |
73 | > When the CPU assigns memory to processes that require it, it typically does so in 4 KB page chunks. Because the CPU’s
74 | > MMU unit actively needs to translate virtual memory to physical memory upon incoming I/O requests, going through all 4
75 | > KB pages is naturally an expensive operation. Fortunately, it has its own TLB cache (translation lookaside buffer),
76 | > which reduces the potential amount of time required to access a specific memory address by caching the most recently
77 | > used memory.
78 |
79 | ### Why Did I Change It?
80 |
81 | As mentioned in the explanation, pages are expensive to allocate. Hugepages are significantly easier to allocate and
82 | look up, and they reduce a lot of stutter when dealing with large amounts of memory.
83 |
84 | ### How It's Done
85 |
86 | ```bash
87 | echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
88 | ```
89 |
90 | ## Shared Memory in Transparent Hugepages
91 |
92 | ### What It Does
93 |
94 | As per [the kernel docs](https://www.kernel.org/doc/html/next/admin-guide/mm/transhuge.html#hugepages-in-tmpfs-shmem):
95 |
96 | > The mount is used for SysV SHM, memfds, shared anonymous mmaps (of /dev/zero or MAP_ANONYMOUS), GPU drivers’ DRM
97 | > objects, Ashmem.
98 |
99 | Essentially, it allows those things to end up in hugepages.
100 |
101 | ### Why Did I Change It?
102 |
103 | For the same reasons as enabling hugepages, this can reduce some latency in memory management.
104 |
105 | ### How It's Done
106 |
107 | ```bash
108 | echo advise | sudo tee /sys/kernel/mm/transparent_hugepage/shmem_enabled
109 | ```
110 |
111 | ## Compaction Proactiveness
112 |
113 | ### What It Does
114 |
115 | This feature proactively defragments memory when Linux detects "downtime".
116 |
117 | ### Why Did I Change It?
118 |
119 | Even the [kernel documentation](https://docs.kernel.org/admin-guide/sysctl/vm.html#compaction-proactiveness) agrees
120 | that this feature has a system-wide impact on performance:
121 |
122 | > Note that compaction has a non-trivial system-wide impact as pages belonging to different processes are moved around,
123 | > which could also lead to latency spikes in unsuspecting applications.
124 |
125 | Essentially, even though Linux tried to detect the proper time to do compaction, there's _never_ a good time during
126 | gaming, so it's best to disable it.
127 |
128 | ### How It's Done
129 |
130 | ```bash
131 | echo 0 | sudo tee /proc/sys/vm/compaction_proactiveness
132 | ```
133 |
134 | ## Hugepage Defragmentation
135 |
136 | ### What It Does
137 |
138 | It's the same thing as proactive compaction, but for hugepages.
139 |
140 | ### Why Did I Change It?
141 |
142 | See the reasons for disabling proactive compaction.
143 |
144 | ### How It's Done
145 |
146 | ```bash
147 | echo 0 | sudo tee /sys/kernel/mm/transparent_hugepage/khugepaged/defrag
148 | ```
149 |
150 | ## Page Lock Unfairness
151 |
152 | ### What It Does
153 |
154 | PLU configures how many times a process can try to get a lock on a page before "fair" behavior kicks in, and guarantees
155 | that process access to a page.
156 | See [the commit](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5ef64cc8987a9211d3f3667331ba3411a94ddc79)
157 | for details.
158 |
159 | ### Why Did I Change It?
160 |
161 | Unfortunately, [it can have negative side effects](https://www.phoronix.com/review/linux-59-fairness), especially in
162 | gaming. Having processes wait repeatedly can cause games to have many issues with stutter, and causes some to sleep
163 | when they shouldn't.
164 |
165 | ### How It's Done
166 |
167 | ```bash
168 | echo 1 | sudo tee /proc/sys/vm/page_lock_unfairness
169 | ```
170 |
171 | ## Sources
172 |
173 | Some wording and general sanity checks were provided by [Emin](https://github.com/xeome), who is likely to be a big
174 | contributor going forward, given his interest in low-level Linux optimizations.
175 |
176 | The rest is provided by [the Arch Wiki](https://wiki.archlinux.org), [Phoronix](https://www.phoronix.com),
177 | [kernel docs](https://docs.kernel.org) and various bits of knowledge that I've gathered over the years.
178 |
--------------------------------------------------------------------------------
/internal/handler_swap.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "bufio"
21 | "fmt"
22 | "os"
23 | "os/exec"
24 | "strconv"
25 | "strings"
26 | )
27 |
28 | // Get swap file location from the system (/proc/swaps)
29 | // Sample output:
30 | // Filename Type Size Used Priority
31 | // /home/swapfile file 8388604 0 -2
32 | func getSwapFileLocation() (string, error) {
33 | file, err := os.Open("/proc/swaps")
34 | if err != nil {
35 | return "", err
36 | }
37 | defer file.Close()
38 |
39 | scanner := bufio.NewScanner(file)
40 | // skip the first line (header)
41 | scanner.Scan()
42 |
43 | for scanner.Scan() {
44 | fields := strings.Fields(scanner.Text())
45 | if len(fields) >= 3 && fields[0] != "Filename" {
46 | location := fields[0]
47 | // If swapfile is a partition then return no swapfile found
48 | if strings.HasPrefix(location, "/dev/") {
49 | return "", fmt.Errorf("no swapfile found")
50 | }
51 | return location, nil
52 | }
53 | }
54 |
55 | if doesFileExist(DefaultSwapFileLocation) {
56 | return DefaultSwapFileLocation, nil
57 | }
58 |
59 | return "", fmt.Errorf("no swapfile found")
60 | }
61 |
62 | // Get the current swap and swappiness values
63 | func getSwappinessValue() (int, error) {
64 | cmd, err := exec.Command("sysctl", "vm.swappiness").Output()
65 | if err != nil {
66 | return 100, fmt.Errorf("error getting current swappiness")
67 | }
68 | output := strings.Fields(string(cmd))
69 | CryoUtils.InfoLog.Println("Found a swappiness of", output[2])
70 | swappiness, _ := strconv.Atoi(output[2])
71 |
72 | return swappiness, nil
73 | }
74 |
75 | // Get current swap file size, in bytes.
76 | func getSwapFileSize() (int64, error) {
77 | location, err := getSwapFileLocation()
78 | if err != nil {
79 | return DefaultSwapSizeBytes, fmt.Errorf("error getting swapfile location: %v", err)
80 | }
81 |
82 | CryoUtils.SwapFileLocation = location
83 |
84 | info, err := os.Stat(CryoUtils.SwapFileLocation)
85 | if err != nil {
86 | // Don't crash the program, just report the default size
87 | return DefaultSwapSizeBytes, fmt.Errorf("error getting current swap file size")
88 | }
89 | CryoUtils.InfoLog.Println("Found a swap file with a size of", info.Size())
90 | return info.Size(), nil
91 | }
92 |
93 | // Get the available space for a swap file and return a slice of strings
94 | func getAvailableSwapSizes() ([]string, error) {
95 | // Get the free space in /home
96 | currentSwapSize, _ := getSwapFileSize()
97 | availableSpace, err := getFreeSpace("/home")
98 | if err != nil {
99 | return nil, fmt.Errorf("error getting available space in /home")
100 | }
101 |
102 | // Loop through the range of available sizes and create a list of viable options for the current Deck.
103 | // This will always leave 1 as an available option, just in case.
104 | validSizes := []string{"1 - Default"}
105 | for _, size := range AvailableSwapSizes {
106 | intSize, _ := strconv.Atoi(size)
107 | byteSize := intSize * GigabyteMultiplier
108 | if int64(byteSize+SpaceOverhead) < (availableSpace + currentSwapSize) {
109 | if byteSize == int(currentSwapSize) {
110 | currentSizeString := fmt.Sprintf("%s - Current Size", size)
111 | validSizes = append(validSizes, currentSizeString)
112 | } else {
113 | validSizes = append(validSizes, size)
114 | }
115 | }
116 | }
117 |
118 | CryoUtils.InfoLog.Println("Available Swap Sizes:", validSizes)
119 | return validSizes, nil
120 | }
121 |
122 | // Disable swapping completely
123 | func disableSwap() error {
124 | CryoUtils.InfoLog.Println("Disabling swap temporarily...")
125 | _, err := exec.Command("sudo", "swapoff", "-a").Output()
126 | if err != nil {
127 | return fmt.Errorf("error disabling swap")
128 | }
129 | return err
130 | }
131 |
132 | // Resize the swap file to the provided size, in GB.
133 | func resizeSwapFile(size int) error {
134 | locationArg := fmt.Sprintf("of=%s", CryoUtils.SwapFileLocation)
135 | countArg := fmt.Sprintf("count=%d", size)
136 |
137 | CryoUtils.InfoLog.Println("Resizing swap to", size, "GB...")
138 | // Use dd to write zeroes, reevaluate using Go directly in the future
139 | _, err := exec.Command("sudo", "dd", "if=/dev/zero", locationArg, "bs=1G", countArg, "status=progress").Output()
140 | if err != nil {
141 | return fmt.Errorf("error resizing %s", CryoUtils.SwapFileLocation)
142 | }
143 | return nil
144 | }
145 |
146 | // Set swap permissions to a valid value.
147 | func setSwapPermissions() error {
148 | CryoUtils.InfoLog.Println("Setting permissions on", CryoUtils.SwapFileLocation, "to 0600...")
149 | _, err := exec.Command("sudo", "chmod", "600", CryoUtils.SwapFileLocation).Output()
150 | if err != nil {
151 | return fmt.Errorf("error setting permissions on %s", CryoUtils.SwapFileLocation)
152 | }
153 | return nil
154 | }
155 |
156 | // Enable swapping on the newly resized file.
157 | func initNewSwapFile() error {
158 | CryoUtils.InfoLog.Println("Enabling swap on", CryoUtils.SwapFileLocation, "...")
159 | _, err := exec.Command("sudo", "mkswap", CryoUtils.SwapFileLocation).Output()
160 | if err != nil {
161 | return fmt.Errorf("error creating swap on %s", CryoUtils.SwapFileLocation)
162 | }
163 | _, err = exec.Command("sudo", "swapon", CryoUtils.SwapFileLocation).Output()
164 | if err != nil {
165 | return fmt.Errorf("error enabling swap on %s", CryoUtils.SwapFileLocation)
166 | }
167 | return nil
168 | }
169 |
170 | // ChangeSwappiness Set swappiness to the provided integer.
171 | func ChangeSwappiness(value string) error {
172 | CryoUtils.InfoLog.Println("Setting swappiness...")
173 | // Remove old swappiness file while we're at it
174 | _ = removeFile(OldSwappinessUnitFile)
175 | err := setUnitValue("swappiness", value)
176 | if err != nil {
177 | return err
178 | }
179 |
180 | if value == DefaultSwappiness {
181 | CryoUtils.InfoLog.Println("Removing swappiness unit to revert to default behavior...")
182 | err = removeUnitFile("swappiness")
183 | if err != nil {
184 | return err
185 | }
186 | } else {
187 | err = writeUnitFile("swappiness", value)
188 | if err != nil {
189 | return err
190 | }
191 | return nil
192 | }
193 |
194 | // Return no error if everything went as planned
195 | return nil
196 | }
197 |
--------------------------------------------------------------------------------
/internal/handler_memory.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | func getHugePagesStatus() bool {
20 | status, err := getUnitStatus("hugepages")
21 | if err != nil {
22 | CryoUtils.ErrorLog.Println("Unable to get current hugepages value")
23 | return false
24 | }
25 | if status == RecommendedHugePages {
26 | return true
27 | }
28 | return false
29 | }
30 |
31 | func getCompactionProactivenessStatus() bool {
32 | status, err := getUnitStatus("compaction_proactiveness")
33 | if err != nil {
34 | CryoUtils.ErrorLog.Println("Unable to get current compaction_proactiveness")
35 | return false
36 | }
37 | if status == RecommendedCompactionProactiveness {
38 | return true
39 | }
40 | return false
41 | }
42 |
43 | func getPageLockUnfairnessStatus() bool {
44 | status, err := getUnitStatus("page_lock_unfairness")
45 | if err != nil {
46 | CryoUtils.ErrorLog.Println("Unable to get current page_lock_unfairness")
47 | return false
48 | }
49 | if status == RecommendedPageLockUnfairness {
50 | return true
51 | }
52 | return false
53 | }
54 |
55 | func getShMemStatus() bool {
56 | status, err := getUnitStatus("shmem_enabled")
57 | if err != nil {
58 | CryoUtils.ErrorLog.Println("Unable to get current shmem_enabled")
59 | return false
60 | }
61 | if status == RecommendedShMem {
62 | return true
63 | }
64 | return false
65 | }
66 |
67 | func getDefragStatus() bool {
68 | status, err := getUnitStatus("defrag")
69 | if err != nil {
70 | CryoUtils.ErrorLog.Println("Unable to get current defrag")
71 | return false
72 | }
73 | if status == RecommendedHugePageDefrag {
74 | return true
75 | }
76 | return false
77 | }
78 |
79 | // ToggleHugePages Simple one-function toggle for the button to use
80 | func ToggleHugePages() error {
81 | if getHugePagesStatus() {
82 | err := RevertHugePages()
83 | if err != nil {
84 | return err
85 | }
86 | } else {
87 | err := SetHugePages()
88 | if err != nil {
89 | return err
90 | }
91 | }
92 | return nil
93 | }
94 |
95 | // ToggleShMem Simple one-function toggle for the button to use
96 | func ToggleShMem() error {
97 | if getShMemStatus() {
98 | err := RevertShMem()
99 | if err != nil {
100 | return err
101 | }
102 | } else {
103 | err := SetShMem()
104 | if err != nil {
105 | return err
106 | }
107 | }
108 | return nil
109 | }
110 |
111 | // ToggleCompactionProactiveness Simple one-function toggle for the button to use
112 | func ToggleCompactionProactiveness() error {
113 | if getCompactionProactivenessStatus() {
114 | err := RevertCompactionProactiveness()
115 | if err != nil {
116 | return err
117 | }
118 | } else {
119 | err := SetCompactionProactiveness()
120 | if err != nil {
121 | return err
122 | }
123 | }
124 | return nil
125 | }
126 |
127 | // ToggleDefrag Simple one-function toggle for the button to use
128 | func ToggleDefrag() error {
129 | if getDefragStatus() {
130 | err := RevertDefrag()
131 | if err != nil {
132 | return err
133 | }
134 | } else {
135 | err := SetDefrag()
136 | if err != nil {
137 | return err
138 | }
139 | }
140 | return nil
141 | }
142 |
143 | // TogglePageLockUnfairness Simple one-function toggle for the button to use
144 | func TogglePageLockUnfairness() error {
145 | if getPageLockUnfairnessStatus() {
146 | err := RevertPageLockUnfairness()
147 | if err != nil {
148 | return err
149 | }
150 | } else {
151 | err := SetPageLockUnfairness()
152 | if err != nil {
153 | return err
154 | }
155 | }
156 | return nil
157 | }
158 |
159 | func SetHugePages() error {
160 | CryoUtils.InfoLog.Println("Enabling hugepages...")
161 | // Remove a file accidentally included in a beta for testing
162 | _ = removeFile(NHPTestingFile)
163 | err := setUnitValue("hugepages", RecommendedHugePages)
164 | if err != nil {
165 | return err
166 | }
167 | err = writeUnitFile("hugepages", RecommendedHugePages)
168 | if err != nil {
169 | return err
170 | }
171 | return nil
172 | }
173 |
174 | func RevertHugePages() error {
175 | CryoUtils.InfoLog.Println("Disabling hugepages...")
176 | err := setUnitValue("hugepages", DefaultHugePages)
177 | if err != nil {
178 | return err
179 | }
180 | err = removeUnitFile("hugepages")
181 | if err != nil {
182 | return err
183 | }
184 | return nil
185 | }
186 |
187 | func SetCompactionProactiveness() error {
188 | CryoUtils.InfoLog.Println("Setting compaction_proactiveness...")
189 | err := setUnitValue("compaction_proactiveness", RecommendedCompactionProactiveness)
190 | if err != nil {
191 | return err
192 | }
193 | err = writeUnitFile("compaction_proactiveness", RecommendedCompactionProactiveness)
194 | if err != nil {
195 | return err
196 | }
197 | return nil
198 | }
199 |
200 | func RevertCompactionProactiveness() error {
201 | CryoUtils.InfoLog.Println("Disabling compaction_proactiveness...")
202 | err := setUnitValue("compaction_proactiveness", DefaultCompactionProactiveness)
203 | if err != nil {
204 | return err
205 | }
206 | err = removeUnitFile("compaction_proactiveness")
207 | if err != nil {
208 | return err
209 | }
210 | return nil
211 | }
212 |
213 | func SetPageLockUnfairness() error {
214 | CryoUtils.InfoLog.Println("Enabling page_lock_unfairness...")
215 | err := setUnitValue("page_lock_unfairness", RecommendedPageLockUnfairness)
216 | if err != nil {
217 | return err
218 | }
219 | err = writeUnitFile("page_lock_unfairness", RecommendedPageLockUnfairness)
220 | if err != nil {
221 | return err
222 | }
223 | return nil
224 | }
225 |
226 | func RevertPageLockUnfairness() error {
227 | CryoUtils.InfoLog.Println("Disabling page_lock_unfairness...")
228 | err := setUnitValue("page_lock_unfairness", DefaultPageLockUnfairness)
229 | if err != nil {
230 | return err
231 | }
232 | err = removeUnitFile("page_lock_unfairness")
233 | if err != nil {
234 | return err
235 | }
236 | return nil
237 | }
238 |
239 | func SetShMem() error {
240 | CryoUtils.InfoLog.Println("Enabling shmem_enabled...")
241 | err := setUnitValue("shmem_enabled", RecommendedShMem)
242 | if err != nil {
243 | return err
244 | }
245 | err = writeUnitFile("shmem_enabled", RecommendedShMem)
246 | if err != nil {
247 | return err
248 | }
249 | return nil
250 | }
251 |
252 | func RevertShMem() error {
253 | CryoUtils.InfoLog.Println("Disabling shmem_enabled...")
254 | err := setUnitValue("shmem_enabled", DefaultShMem)
255 | if err != nil {
256 | return err
257 | }
258 | err = removeUnitFile("shmem_enabled")
259 | if err != nil {
260 | return err
261 | }
262 | return nil
263 | }
264 |
265 | func SetDefrag() error {
266 | CryoUtils.InfoLog.Println("Enabling shmem_enabled...")
267 | err := setUnitValue("defrag", RecommendedHugePageDefrag)
268 | if err != nil {
269 | return err
270 | }
271 | err = writeUnitFile("defrag", RecommendedHugePageDefrag)
272 | if err != nil {
273 | return err
274 | }
275 | return nil
276 | }
277 |
278 | func RevertDefrag() error {
279 | CryoUtils.InfoLog.Println("Disabling shmem_enabled...")
280 | err := setUnitValue("defrag", DefaultHugePageDefrag)
281 | if err != nil {
282 | return err
283 | }
284 | err = removeUnitFile("defrag")
285 | if err != nil {
286 | return err
287 | }
288 | return nil
289 | }
290 |
--------------------------------------------------------------------------------
/cmd/cryoutilities/main.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package main
18 |
19 | import (
20 | "context"
21 | "cryoutilities/internal"
22 | "errors"
23 | "log"
24 | "os"
25 | "strconv"
26 | "strings"
27 |
28 | "github.com/cristalhq/acmd"
29 | )
30 |
31 | func main() {
32 | // Delete old log file
33 | os.Remove(internal.LogFilePath)
34 | // Create a log file
35 | logFile, err := os.OpenFile(internal.LogFilePath, os.O_RDWR|os.O_CREATE, 0666)
36 | if err != nil {
37 | log.Panic(err)
38 | }
39 | defer logFile.Close()
40 | log.SetOutput(logFile)
41 |
42 | // Create loggers
43 | internal.CryoUtils.InfoLog = log.New(logFile, "INFO\t", log.Ldate|log.Ltime)
44 | internal.CryoUtils.ErrorLog = log.New(logFile, "ERROR\t", log.Ldate|log.Ltime|log.Lshortfile)
45 |
46 | // Print the current version as a test
47 | internal.CryoUtils.InfoLog.Println("Current Version:", internal.CurrentVersionNumber)
48 |
49 | // Provide a command structure for parsing
50 | cmds := []acmd.Command{
51 | {
52 | Name: "gui",
53 | Description: "Run in GUI mode",
54 | ExecFunc: func(context.Context, []string) error {
55 | internal.InitUI()
56 | return nil
57 | },
58 | },
59 | {
60 | Name: "swap",
61 | Description: "Change swap file size in increments of 1GB.",
62 | ExecFunc: func(_ context.Context, args []string) error {
63 | internal.CryoUtils.InfoLog.Println("Starting swap file resize...")
64 | size, err := strconv.Atoi(args[0])
65 | if err != nil {
66 | return err
67 | }
68 | err = internal.ChangeSwapSizeCLI(size, false)
69 | if err != nil {
70 | return err
71 | }
72 | internal.CryoUtils.InfoLog.Println("Success!")
73 | return nil
74 | },
75 | },
76 | {
77 | Name: "swappiness",
78 | Description: "Change swappiness to the specified value 0-200.",
79 | ExecFunc: func(_ context.Context, args []string) error {
80 | internal.CryoUtils.InfoLog.Println("Starting swappiness change...")
81 | swappiness := args[0]
82 | swappinessInt, err := strconv.Atoi(swappiness)
83 | if err != nil || swappinessInt < 0 || swappinessInt > 200 {
84 | return errors.New("invalid swappiness value")
85 | }
86 | err = internal.ChangeSwappiness(swappiness)
87 | if err != nil {
88 | return err
89 | }
90 | internal.CryoUtils.InfoLog.Println("Success!")
91 | return nil
92 | },
93 | },
94 | {
95 | Name: "hugepages",
96 | Description: "Enable or disable hugepages. Accepts 'true', 'false', 'enable' or 'disable'.\n\tRecommended: Enabled",
97 | ExecFunc: func(_ context.Context, args []string) error {
98 | arg := strings.ToLower(args[0])
99 | if arg == "true" || arg == "enable" {
100 | internal.CryoUtils.InfoLog.Println("Enabling HugePages...")
101 | err := internal.SetHugePages()
102 | if err != nil {
103 | return err
104 | }
105 | } else if arg == "false" || arg == "disable" {
106 | internal.CryoUtils.InfoLog.Println("Disabling HugePages...")
107 | err := internal.RevertHugePages()
108 | if err != nil {
109 | return err
110 | }
111 | } else {
112 | return errors.New("invalid argument provided")
113 | }
114 | return nil
115 | },
116 | },
117 | {
118 | Name: "compaction_proactiveness",
119 | Description: "Set or revert compaction proactiveness. Accepts 'recommended' or 'stock'.",
120 | ExecFunc: func(_ context.Context, args []string) error {
121 | arg := strings.ToLower(args[0])
122 | if arg == "recommended" {
123 | internal.CryoUtils.InfoLog.Println("Setting Compaction Proactiveness...")
124 | err := internal.SetCompactionProactiveness()
125 | if err != nil {
126 | return err
127 | }
128 | } else if arg == "stock" {
129 | internal.CryoUtils.InfoLog.Println("Reverting Compaction Proactiveness...")
130 | err := internal.RevertCompactionProactiveness()
131 | if err != nil {
132 | return err
133 | }
134 | } else {
135 | return errors.New("invalid argument provided")
136 | }
137 | return nil
138 | },
139 | },
140 | {
141 | Name: "defrag",
142 | Description: "Enable or disable hugepage defrag. Accepts 'true', 'false', 'enable' or 'disable'.\n\tRecommended: Disabled",
143 | ExecFunc: func(_ context.Context, args []string) error {
144 | arg := strings.ToLower(args[0])
145 | if arg == "true" || arg == "enable" {
146 | internal.CryoUtils.InfoLog.Println("Enabling HugePAge Defrag...")
147 | err := internal.RevertDefrag()
148 | if err != nil {
149 | return err
150 | }
151 | } else if arg == "false" || arg == "disable" {
152 | internal.CryoUtils.InfoLog.Println("Revert Compaction Proactiveness...")
153 | err := internal.SetDefrag()
154 | if err != nil {
155 | return err
156 | }
157 | } else {
158 | return errors.New("invalid argument provided")
159 | }
160 | return nil
161 | },
162 | },
163 | {
164 | Name: "page_lock_unfairness",
165 | Description: "Set or revert page lock unfairness. Accepts 'recommended' or 'stock'.",
166 | ExecFunc: func(_ context.Context, args []string) error {
167 | arg := strings.ToLower(args[0])
168 | if arg == "recommended" {
169 | internal.CryoUtils.InfoLog.Println("Setting Page Lock Unfairness...")
170 | err := internal.SetPageLockUnfairness()
171 | if err != nil {
172 | return err
173 | }
174 | } else if arg == "stock" {
175 | internal.CryoUtils.InfoLog.Println("Reverting Page Lock Unfairness...")
176 | err := internal.RevertPageLockUnfairness()
177 | if err != nil {
178 | return err
179 | }
180 | } else {
181 | return errors.New("invalid argument provided")
182 | }
183 | return nil
184 | },
185 | },
186 | {
187 | Name: "shmem",
188 | Description: "Enable or disable shared memory. Accepts 'true', 'false', 'enable' or 'disable'.\n\tRecommended: Enabled",
189 | ExecFunc: func(_ context.Context, args []string) error {
190 | arg := strings.ToLower(args[0])
191 | if arg == "true" || arg == "enable" {
192 | internal.CryoUtils.InfoLog.Println("Setting Shared Memory...")
193 | err := internal.SetShMem()
194 | if err != nil {
195 | return err
196 | }
197 | } else if arg == "false" || arg == "disable" {
198 | internal.CryoUtils.InfoLog.Println("Reverting Shared Memory...")
199 | err := internal.RevertShMem()
200 | if err != nil {
201 | return err
202 | }
203 | } else {
204 | return errors.New("invalid argument provided")
205 | }
206 | return nil
207 | },
208 | },
209 | {
210 | Name: "recommended",
211 | Description: "Set all values to Cryo's recommendations.",
212 | ExecFunc: func(context.Context, []string) error {
213 | err := internal.UseRecommendedSettings()
214 | if err != nil {
215 | return err
216 | }
217 | return nil
218 | },
219 | },
220 | {
221 | Name: "stock",
222 | Description: "Set all values to Valve defaults.",
223 | ExecFunc: func(context.Context, []string) error {
224 | err := internal.UseStockSettings()
225 | if err != nil {
226 | return err
227 | }
228 | return nil
229 | },
230 | },
231 | }
232 |
233 | // If no args are passed, assume "gui"
234 | if len(os.Args) <= 1 {
235 | os.Args = []string{"", "gui"}
236 | }
237 |
238 | // Basic program metadata
239 | r := acmd.RunnerOf(cmds, acmd.Config{
240 | AppName: "cryoutilities",
241 | AppDescription: "CryoByte33's Steam Deck utility script.",
242 | PostDescription: "NOTE: You NEED to run this with sudo if not using GUI mode.",
243 | Version: internal.CurrentVersionNumber,
244 | })
245 |
246 | // Run the command parser
247 | if err := r.Run(); err != nil {
248 | internal.CryoUtils.ErrorLog.Println(err)
249 | os.Exit(1)
250 | }
251 | }
252 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CryoUtilities
2 |
3 | Scripts and utilities to improve performance and manage storage on the Steam Deck. (May work with other Linux distros.)
4 |
5 | [](https://www.youtube.com/@cryobyte33)
6 | [](https://patreon.com/cryobyte33)
7 |
8 | ## Update
9 |
10 | ### Notes on the Steam Deck OLED
11 | The latest update resolves the scaling issues on the new OLED Deck, and I figured I should provide an update here:
12 | 1. **This (CU2) is still fully compatible with the new OLED models.**
13 | 2. Performance improvements should be similar (or possibly slightly better) than on the LCD model (thorough testing pending)
14 |
15 | ### General Linux Compatibility
16 | As of the latest update, this _should_ be compatible with most Linux systems, with the following limitations:
17 | 1. This will not operate on swap partitions, only files.
18 | 2. The Game Data and VRAM tabs will likely not work
19 | 3. Pop_OS! has a custom swappiness that will override any value set here after reboot.
20 |
21 | Please keep in mind that support for non-Steam Deck devices is on a "best effort" basis, and will have a low priority.
22 | Unfortunately, the amount of effort and support that would be needed to guarantee functionality for all distros would
23 | require me to be working on this full-time, which is not the case.
24 |
25 | If you want to use the tweaks here without relying on this tool, please see the "How Does it Work" section below.
26 |
27 | ### VRAM Tab
28 | There's a new VRAM tab which will tell you the current "UMA Frame Buffer Size" setting, and how to configure it if
29 | you haven't already!
30 |
31 | ### Swap Improvements
32 | The swapfile path is now completely dynamic and the resize functionality can recover in the event of an earlier failure!
33 | You no longer need to manually intervene if a previous swap resize failed, just run the resize again and it'll work its
34 | magic.
35 |
36 | ### One-Click Game Data Cleanup
37 | There's now a simple "Delete all uninstalled" button in the "Clean Game Data" window. Just click it and all the data
38 | from uninstalled games will be removed!
39 |
40 | **Please keep in mind that non-cloud-saved save games should still be backed up manually before using this.**
41 |
42 | ## Explanation and Tutorial
43 |
44 | If you're interested, please see the [announcement video here](https://youtu.be/C9EjXYZUqUs), where I go over all the
45 | new features and how they work.
46 |
47 | ## Functionality
48 |
49 | * One-click set-to-recommended settings
50 | * One-click revert-to-stock settings
51 | * Swap Tuner
52 | * Swap File Resizer + Recovery
53 | * Swappiness Changer
54 | * Memory Parameter Tuning
55 | * HugePages Toggle
56 | * Compaction Proactiveness Changer
57 | * HugePage Defragmentation Toggle
58 | * Page Lock Unfairness Changer
59 | * Shared Memory (shmem) Toggle
60 | * Storage Manager
61 | * Sync shadercache and compatdata to the same location the game is installed
62 | * Delete shadercache and compatdata for whichever games you select
63 | * Delete the shadercache and compatdata for all uninstalled games with a single click
64 | * Full CLI mode
65 |
66 | Look below for common questions and answers, or go check out my [YouTube Channel](https://www.youtube.com/@cryobyte33)
67 | for examples on how to use this and what performance you can expect.
68 |
69 | ## Install
70 |
71 | ### Simple
72 |
73 | [Download this link](https://raw.githubusercontent.com/CryoByte33/steam-deck-utilities/main/InstallCryoUtilities.desktop)
74 | to your desktop (right click and save file) on your Steam Deck, remove the `.download` from the end of the file name,
75 | then double-click it.
76 |
77 | This will install the program, create desktop icons, and create menu entries.
78 |
79 | ### Manual
80 |
81 | See [manual-install.md](https://github.com/CryoByte33/steam-deck-utilities/blob/main/docs/manual-install.md).
82 |
83 | ### Offline/Firewalled
84 |
85 | In case you're in a firewalled country like China, please see [this post on my website](https://cryobyte.io/posts/2023/03/cryoutilities-offline-installation/)
86 | for install directions and a non-GitHub download link.
87 |
88 | ## Usage
89 |
90 | **NOTE:** This **REQUIRES** a password set on the Steam Deck. That can be done with the `passwd` command.
91 |
92 | ### GUI
93 |
94 | After installation, just run the "CryoUtilities" icon on the desktop or the application menu under "Utilities".
95 |
96 | ### CLI
97 |
98 | The latest version has a full CLI handler, which can be used to perform all tweaks, but doesn't perform game data
99 | operations.
100 |
101 | ```
102 | sudo ~/.cryo_utilities/cryo_utilities [parameter]
103 | ```
104 |
105 | If you want to see the available commands and accepted values, you can use:
106 |
107 | ```
108 | sudo ~/.cryo_utilities/cryo_utilities help
109 | ```
110 |
111 | **Note:** You _need_ to use sudo for the tweaks to work, otherwise it can't write to the necessary locations on disk.
112 |
113 | ## Upgrade
114 |
115 | Double-click the "Update CryoUtilities" icon on the desktop, you will get a dialog box when the update is complete.
116 |
117 | ## Uninstall
118 |
119 | Double-click the "Uninstall CryoUtilities" icon on the desktop, you will be asked if you're sure, then asked if you want
120 | to revert the tweaks that have been made.
121 |
122 | ## Revert To Default Settings
123 |
124 | To revert to the Steam Deck defaults, do one of the following:
125 |
126 | * Boot CryoUtilities and click "Stock" on the homepage.
127 | * Uninstall CryoUtilities, you'll be asked if you want to revert to stock settings. Choose yes.
128 |
129 | After choosing these options, the Deck will be identical to an unmodified version.
130 |
131 | ## Known Issues
132 |
133 | * If the drive becomes full during the swap file resize, you can trigger a known SteamOS bug that causes boot loops.
134 | * CryoUtilities is programmed in such a way to not allow this, but in the very worst cases it's still possible if
135 | something is operating/downloading in the background, at the same time CryoUtilities resizes the swap file.
136 | * In the event that it happens, you need to either get into a live environment and delete some files, or reinstall
137 | SteamOS with the non-destructive method.
138 | * While using CLI mode, it is possible that the swap file resize takes long enough that the sudo credentials will time
139 | out.
140 | * This does not occur in GUI mode, due to how I was able to implement authentication, and will be patched out of
141 | CLI-only mode soon.
142 |
143 | ## FAQ
144 |
145 | See [the FAQ page](https://github.com/CryoByte33/steam-deck-utilities/blob/main/docs/faq.md).
146 |
147 | ## What does it do?
148 |
149 | See [the tweak explanation page](https://github.com/CryoByte33/steam-deck-utilities/blob/main/docs/tweak-explanation.md).
150 |
151 | ## Troubleshooting
152 |
153 | ### CryoUtilities doesn't appear after double-clicking the icon on the desktop
154 |
155 | * Make sure that you're using SteamOS 3.4 or later
156 | * Verify that `/home/deck/.cryo_utilities/cryo_utilities` and `/home/deck/.cryo_utilities/launcher.sh` exist
157 | * `/home/deck/.cryo_utilities` is a hidden directory, so ensure that you can view hidden files
158 |
159 | If the above doesn't work, please open an issue here or contact in the [Discord](https://discord.gg/ySe8WGVNPv)!
160 |
161 | ### I have instability in a game after using CryoUtilities' recommended settings
162 |
163 | Try rebooting the Deck and trying again, I haven't heard of instability post-reboot, but if you find some please let
164 | me know!
165 |
166 | ### Right-clicking the link to save it doesn't open a dialog box
167 |
168 | Reboot the Deck or restart desktop mode, afterwards the link should work.
169 |
170 | ### The .desktop file just opens with KWrite after I download it.
171 |
172 | Make sure the `CryoUtilities.desktop` file is on the desktop when you run it. If that still doesn't work, try one of the
173 | following:
174 |
175 | * Run `chmod +x ~/Downloads/InstallCryoUtilities.desktop` and then try again.
176 | * Add `CryoUtilities.desktop` as a Non-Steam game and run it from Steam.
177 |
178 | ### The swap resize times out
179 |
180 | Go to Game Mode, navigate to Settings > System, then press "Run storage device maintenance tasks" at the very bottom.
181 | After it's completed, you should be able to resize the swap file easily.
182 |
183 | ### Trying to do anything crashes the program
184 |
185 | Make sure that you installed using the installer. If you can't, then run:
186 |
187 | ```bash
188 | chown -R deck:deck ~/.cryo_utilities
189 | chmod -R 777 ~/.cryo_utilities
190 | ```
191 |
192 | These permissions are more open than necessary, though, so only do it as a last resort.
193 |
194 |
--------------------------------------------------------------------------------
/internal/util.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "bytes"
21 | "errors"
22 | "fmt"
23 | "io"
24 | "log"
25 | "os"
26 | "os/exec"
27 | "path/filepath"
28 | "strings"
29 | "time"
30 |
31 | "fyne.io/fyne/v2"
32 | "fyne.io/fyne/v2/canvas"
33 | "fyne.io/fyne/v2/widget"
34 | "github.com/moby/sys/mountinfo"
35 | "golang.org/x/sys/unix"
36 | )
37 |
38 | type Config struct {
39 | App fyne.App
40 | InfoLog *log.Logger
41 | ErrorLog *log.Logger
42 | SwapText *canvas.Text
43 | SwappinessText *canvas.Text
44 | HugePagesText *canvas.Text
45 | ShMemText *canvas.Text
46 | CompactionProactivenessText *canvas.Text
47 | DefragText *canvas.Text
48 | PageLockUnfairnessText *canvas.Text
49 | VRAMText *canvas.Text
50 | SteamAPIResponse map[int]string
51 | MainWindow fyne.Window
52 | SwapResizeProgressBar *widget.ProgressBar
53 | MoveDataProgressBar *widget.ProgressBar
54 | HomeContainer *fyne.Container
55 | GameDataContainer *fyne.Container
56 | MemoryContainer *fyne.Container
57 | SwapBar *fyne.Container
58 | MemoryBar *fyne.Container
59 | HugePagesButton *widget.Button
60 | ShMemButton *widget.Button
61 | CompactionProactivenessButton *widget.Button
62 | DefragButton *widget.Button
63 | PageLockUnfairnessButton *widget.Button
64 | VRAMButton *widget.Button
65 | UserPassword string
66 | SwapFileLocation string
67 | }
68 |
69 | var CryoUtils Config
70 |
71 | var stat unix.Statfs_t
72 |
73 | func getFreeSpace(path string) (int64, error) {
74 | err := unix.Statfs(path, &stat)
75 | if err != nil {
76 | CryoUtils.ErrorLog.Println(err)
77 | return 0, fmt.Errorf("error getting free space")
78 | }
79 | return int64(stat.Bfree * uint64(stat.Bsize)), nil
80 | }
81 |
82 | func getDirectorySize(path string) int64 {
83 | var size int64
84 | _ = filepath.Walk(path, func(_ string, info os.FileInfo, _ error) error {
85 | if !info.IsDir() {
86 | size += info.Size()
87 | }
88 | return nil
89 | })
90 | return size
91 | }
92 |
93 | func isSymbolicLink(path string) bool {
94 | fi, err := os.Lstat(path)
95 | if err != nil {
96 | CryoUtils.ErrorLog.Println("Unable to determine if file was symlink:", path)
97 | panic(err)
98 | }
99 |
100 | if fi.Mode()&os.ModeSymlink != 0 {
101 | return true
102 | }
103 | return false
104 | }
105 |
106 | func contains(s []string, str string) bool {
107 | for _, v := range s {
108 | if v == str {
109 | return true
110 | }
111 | }
112 |
113 | return false
114 | }
115 |
116 | func waitForDeletion(path string, directory string) {
117 | for {
118 | if !doesDirectoryExist(path, directory) {
119 | break
120 | }
121 | time.Sleep(time.Second)
122 | }
123 | }
124 |
125 | // Checks the path variable until directory is no longer found, then exits.
126 | func doesDirectoryExist(path string, directory string) bool {
127 | directories, _ := os.ReadDir(path)
128 | for _, dir := range directories {
129 | if dir.Name() == directory {
130 | return true
131 | }
132 | }
133 | return false
134 | }
135 |
136 | func doesFileExist(path string) bool {
137 | _, err := os.Stat(path)
138 | if errors.Is(err, os.ErrNotExist) {
139 | return false
140 | } else {
141 | return true
142 | }
143 | }
144 |
145 | func isSubPath(parent string, sub string) bool {
146 | subFolds := filepath.SplitList(sub)
147 | for i, fold := range filepath.SplitList(parent) {
148 | if subFolds[i] != fold {
149 | return false
150 | }
151 | }
152 | return true
153 | }
154 |
155 | // Write a file with a given string
156 | func writeFile(path string, contents string) error {
157 | CryoUtils.InfoLog.Println("Writing", path)
158 |
159 | tempPath := filepath.Join(InstallDirectory, "temp.txt")
160 | // Try to remove tempfile just in case it exists for some reason
161 | _ = removeFile(tempPath)
162 | // Write to the CU install directory to avoid permissions issues
163 | f, err := os.Create(tempPath)
164 | if err != nil {
165 | CryoUtils.ErrorLog.Println(err)
166 | return err
167 | }
168 |
169 | defer f.Close()
170 |
171 | _, err = f.WriteString(contents)
172 | if err != nil {
173 | CryoUtils.ErrorLog.Println(err)
174 | return err
175 | }
176 |
177 | // Move the completed file to final location.
178 | _, err = exec.Command("sudo", "mv", tempPath, path).Output()
179 | if err != nil {
180 | return fmt.Errorf("error moving temp file to final location")
181 | }
182 |
183 | return nil
184 | }
185 |
186 | func removeFile(path string) error {
187 | CryoUtils.InfoLog.Println("Removing", path)
188 | _, err := exec.Command("sudo", "rm", path).Output()
189 | if err != nil {
190 | CryoUtils.ErrorLog.Println("Couldn't delete", path, ", likely missing.")
191 | }
192 | return nil
193 | }
194 |
195 | // getListOfDataAllDataLocations Get a list off all data locations (compat and shader data).
196 | func getListOfDataAllDataLocations() ([]string, error) {
197 | drives, err := getListOfAttachedDrives()
198 | if err != nil {
199 | CryoUtils.ErrorLog.Println(err)
200 | return nil, err
201 | }
202 |
203 | var possibleLocations []string
204 | for x := range drives {
205 | if drives[x] == SteamDataRoot {
206 | possibleLocations = append(possibleLocations, SteamCompatRoot)
207 | possibleLocations = append(possibleLocations, SteamShaderRoot)
208 | } else {
209 | compat := filepath.Join(drives[x], ExternalCompatRoot)
210 | shader := filepath.Join(drives[x], ExternalShaderRoot)
211 | possibleLocations = append(possibleLocations, compat)
212 | possibleLocations = append(possibleLocations, shader)
213 | }
214 | }
215 |
216 | return possibleLocations, nil
217 | }
218 |
219 | func getListOfAttachedDrives() ([]string, error) {
220 | drives := []string{SteamDataRoot}
221 | filter := mountinfo.PrefixFilter(MountDirectory)
222 | info, err := mountinfo.GetMounts(filter)
223 | if err != nil {
224 | CryoUtils.ErrorLog.Println(err)
225 | return nil, err
226 | }
227 | for x := range info {
228 | drives = append(drives, info[x].Mountpoint)
229 | }
230 | CryoUtils.InfoLog.Printf("Attached drives: %s", drives)
231 | return drives, nil
232 | }
233 |
234 | func removeElementFromStringSlice(str string, slice []string) []string {
235 | var newSlice []string
236 | for x := range slice {
237 | if str != slice[x] {
238 | newSlice = append(newSlice, slice[x])
239 | }
240 | }
241 | return newSlice
242 | }
243 |
244 | func getUnitStatus(param string) (string, error) {
245 | var output string
246 | cmd, err := exec.Command("sudo", "cat", UnitMatrix[param]).Output()
247 | if err != nil {
248 | CryoUtils.ErrorLog.Println(err)
249 | return "nil", err
250 | }
251 | // This is just to get the actual value in units which present as a list.
252 | if strings.Contains(string(cmd), "[") {
253 | slice := strings.Fields(string(cmd))
254 | for x := range slice {
255 | if strings.Contains(slice[x], "[") {
256 | output = strings.ReplaceAll(slice[x], "[", "")
257 | output = strings.ReplaceAll(output, "]", "")
258 | }
259 | }
260 | } else {
261 | output = strings.TrimSpace(string(cmd))
262 | }
263 | return output, nil
264 | }
265 |
266 | func writeUnitFile(param string, value string) error {
267 | path := filepath.Join(TmpFilesRoot, param+".conf")
268 | CryoUtils.InfoLog.Println("Writing", value, "to", path, "to preserve", param, "setting...")
269 | contents := strings.ReplaceAll(TemplateUnitFile, "PARAM", UnitMatrix[param])
270 | contents = strings.ReplaceAll(contents, "VALUE", value)
271 | err := writeFile(path, contents)
272 | if err != nil {
273 | CryoUtils.ErrorLog.Println(err)
274 | return err
275 | }
276 | return nil
277 | }
278 |
279 | func removeUnitFile(param string) error {
280 | path := filepath.Join(TmpFilesRoot, param+".conf")
281 | CryoUtils.InfoLog.Println("Removing", path, "to revert", param, "setting...")
282 | err := removeFile(path)
283 | if err != nil {
284 | CryoUtils.ErrorLog.Println(err)
285 | return err
286 | }
287 | return nil
288 | }
289 |
290 | func setUnitValue(param string, value string) error {
291 | CryoUtils.InfoLog.Println("Writing", value, "for param", param, "to memory.")
292 | // This mess is the only way I could find to push directly to unit files, without requiring
293 | // a sudo password on installation to change capabilities.
294 | echoCmd := exec.Command("echo", value)
295 | teeCmd := exec.Command("sudo", "tee", UnitMatrix[param])
296 | reader, writer := io.Pipe()
297 | var buf bytes.Buffer
298 | echoCmd.Stdout = writer
299 | teeCmd.Stdin = reader
300 | teeCmd.Stdout = &buf
301 | echoCmd.Start()
302 | teeCmd.Start()
303 | echoCmd.Wait()
304 | writer.Close()
305 | teeCmd.Wait()
306 | reader.Close()
307 | io.Copy(os.Stdout, &buf)
308 |
309 | return nil
310 | }
311 |
312 | func getHumanVRAMSize(size int) string {
313 | // Converts the VRAM size to human-readable format.
314 | // The size argument is in MB.
315 | text := fmt.Sprintf("%dMB", size)
316 | if size >= 1024 {
317 | text = fmt.Sprintf("%dGB", size/1024)
318 | }
319 |
320 | return text
321 | }
322 |
323 | func removeGameData(removeList []string, locations []string) {
324 |
325 | CryoUtils.InfoLog.Println("Removing the following content:")
326 | for i := range removeList {
327 | for j := range locations {
328 | path := filepath.Join(locations[j], removeList[i])
329 | CryoUtils.InfoLog.Println(path)
330 | err := os.RemoveAll(path)
331 | if err != nil {
332 | CryoUtils.ErrorLog.Println(err)
333 | presentErrorInUI(err, CryoUtils.MainWindow)
334 | }
335 | }
336 | }
337 | }
338 |
--------------------------------------------------------------------------------
/internal/ui_util.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "fmt"
21 | "fyne.io/fyne/v2"
22 | "fyne.io/fyne/v2/dialog"
23 | "fyne.io/fyne/v2/widget"
24 | "path/filepath"
25 | "sort"
26 | "strconv"
27 | )
28 |
29 | type GameStatus struct {
30 | GameName string
31 | IsInstalled bool
32 | }
33 |
34 | // Show an error message over the main window.
35 | func presentErrorInUI(err error, win fyne.Window) {
36 | CryoUtils.ErrorLog.Println(err)
37 | dialog.ShowError(err, win)
38 | }
39 |
40 | // Create a CheckGroup of game data to allow for selection.
41 | func createGameDataList() (*widget.CheckGroup, error) {
42 | cleanupList := widget.NewCheckGroup([]string{}, func(strings []string) {})
43 | cleanupList.Enable()
44 | cleanupList.Refresh()
45 |
46 | localGames, err := getLocalGameList()
47 | if err != nil {
48 | return nil, err
49 | }
50 |
51 | var sortedMap []int
52 |
53 | for i := range localGames {
54 | // Add each key to the sortedMap slice, so we can sort it afterwards.
55 | sortedMap = append(sortedMap, i)
56 | }
57 | // Sort the slice
58 | sort.Ints(sortedMap)
59 |
60 | // For each entry in the completed list, add an entry to the check group to return
61 | for key := range sortedMap {
62 | // Skips non-game prefixes
63 | if sortedMap[key] == 0 || sortedMap[key] >= SteamGameMaxInteger {
64 | continue
65 | }
66 |
67 | var optionStr string
68 | var gameStr string
69 |
70 | // If the game name is known, use that, otherwise ???.
71 | if localGames[sortedMap[key]].GameName != "" {
72 | gameStr = localGames[sortedMap[key]].GameName
73 | } else {
74 | gameStr = "???"
75 | }
76 |
77 | if localGames[sortedMap[key]].IsInstalled {
78 | optionStr = fmt.Sprintf("%d - %s - Installed", sortedMap[key], gameStr)
79 | } else {
80 | optionStr = fmt.Sprintf("%d - %s - Not Installed", sortedMap[key], gameStr)
81 | }
82 | cleanupList.Append(optionStr)
83 | }
84 |
85 | return cleanupList, nil
86 | }
87 |
88 | func getLocalGameList() (map[int]GameStatus, error) {
89 | // Use the cached API Response if already present
90 | if CryoUtils.SteamAPIResponse == nil {
91 | // Make a map of all games stored in the steam API
92 | steamResponse, err := querySteamAPI()
93 | if err != nil {
94 | CryoUtils.ErrorLog.Println(err)
95 | }
96 | CryoUtils.SteamAPIResponse = generateGameMap(steamResponse)
97 | }
98 |
99 | // Get a list of games that Steam classifies as installed
100 | libraries, err := findDataFolders()
101 | if err != nil {
102 | return nil, err
103 | }
104 | // Get a list of all the folders in each location
105 | var storage []string
106 | for i := range libraries {
107 | // Get the paths to crawl
108 | var compat, shader string
109 | if libraries[i].Path == SteamDataRoot {
110 | compat = SteamCompatRoot
111 | shader = SteamShaderRoot
112 | } else {
113 | compat = filepath.Join(libraries[i].Path, ExternalCompatRoot)
114 | shader = filepath.Join(libraries[i].Path, ExternalShaderRoot)
115 | }
116 |
117 | // Crawl the compat path and append the folders
118 | // Append if no error, to prevent crashing for users that haven't synced data first.
119 | dir, _ := getDirectoryList(compat, true)
120 | if err == nil {
121 | storage = append(storage, dir...)
122 | }
123 |
124 | // Crawl the shader path and append the folders
125 | // Append if no error, to prevent crashing for users that haven't synced data first.
126 | dir, _ = getDirectoryList(shader, true)
127 | if err == nil {
128 | storage = append(storage, dir...)
129 | }
130 | }
131 |
132 | // Store all games present on the filesystem, in all compat and shader directories
133 | localGames := make(map[int]GameStatus)
134 |
135 | for i := range storage {
136 | intGame, _ := strconv.Atoi(storage[i])
137 | localGames[intGame] = GameStatus{
138 | GameName: CryoUtils.SteamAPIResponse[intGame],
139 | IsInstalled: false,
140 | }
141 | }
142 |
143 | // Loop through each library location's installed games
144 | for i := range libraries {
145 | for j := range libraries[i].InstalledGames {
146 | // If the game has an entry in the list of localGames, then update the isInstalled flag to true for that game.
147 | val, keyExists := localGames[libraries[i].InstalledGames[j]]
148 | if keyExists {
149 | val.IsInstalled = true
150 | localGames[libraries[i].InstalledGames[j]] = val
151 | }
152 | }
153 | }
154 | return localGames, nil
155 | }
156 |
157 | // Get data to move values as canvas elements.
158 | func getDataToMoveUI(data DataToMove) (*widget.List, *widget.List, error) {
159 | var leftList, rightList *widget.List
160 |
161 | // Use the cached API Response if already present
162 | if CryoUtils.SteamAPIResponse == nil {
163 | // Make a map of all games stored in the steam API
164 | steamResponse, err := querySteamAPI()
165 | if err != nil {
166 | CryoUtils.ErrorLog.Println(err)
167 | }
168 | CryoUtils.SteamAPIResponse = generateGameMap(steamResponse)
169 | }
170 |
171 | // Get lists of data to move
172 | leftList = widget.NewList(
173 | func() int {
174 | return len(data.right)
175 | },
176 | func() fyne.CanvasObject {
177 | return widget.NewLabel("Left Side")
178 | },
179 | func(i widget.ListItemID, o fyne.CanvasObject) {
180 | gameInt, _ := strconv.Atoi(data.right[i])
181 | gameName := CryoUtils.SteamAPIResponse[gameInt]
182 |
183 | o.(*widget.Label).SetText(data.right[i] + " - " + gameName)
184 | })
185 |
186 | rightList = widget.NewList(
187 | func() int {
188 | return len(data.left)
189 | },
190 | func() fyne.CanvasObject {
191 | return widget.NewLabel("Right Side")
192 | },
193 | func(i widget.ListItemID, o fyne.CanvasObject) {
194 | gameInt, _ := strconv.Atoi(data.left[i])
195 | gameName := CryoUtils.SteamAPIResponse[gameInt]
196 |
197 | o.(*widget.Label).SetText(data.left[i] + " - " + gameName)
198 | })
199 |
200 | return leftList, rightList, nil
201 | }
202 |
203 | func (app *Config) refreshSwapContent() {
204 | app.InfoLog.Println("Refreshing Swap data...")
205 | swap, err := getSwapFileSize()
206 | if err != nil {
207 | CryoUtils.ErrorLog.Println(err)
208 | swapStr := "Current Swap Size: Unknown"
209 | app.SwapText.Text = swapStr
210 | app.SwapText.Color = Gray
211 | } else {
212 | humanSwapSize := swap / int64(GigabyteMultiplier)
213 | swapStr := fmt.Sprintf("Current Swap Size: %dGB", humanSwapSize)
214 | app.SwapText.Text = swapStr
215 | if swap >= RecommendedSwapSizeBytes {
216 | app.SwapText.Color = Green
217 | } else {
218 | app.SwapText.Color = Red
219 | }
220 | }
221 |
222 | app.SwapText.Refresh()
223 | }
224 |
225 | func (app *Config) refreshSwappinessContent() {
226 | app.InfoLog.Println("Refreshing Swappiness data...")
227 | swappiness, err := getSwappinessValue()
228 | if err != nil {
229 | CryoUtils.ErrorLog.Println(err)
230 | swappinessStr := "Current Swappiness: Unknown"
231 | app.SwappinessText.Text = swappinessStr
232 | app.SwappinessText.Color = Gray
233 | } else {
234 | swappinessStr := fmt.Sprintf("Current Swappiness: %d", swappiness)
235 | app.SwappinessText.Text = swappinessStr
236 | if strconv.Itoa(swappiness) == RecommendedSwappiness {
237 | app.SwappinessText.Color = Green
238 | } else {
239 | app.SwappinessText.Color = Red
240 | }
241 | }
242 |
243 | app.SwappinessText.Refresh()
244 | }
245 |
246 | func (app *Config) refreshHugePagesContent() {
247 | app.InfoLog.Println("Refreshing HugePages data...")
248 | if getHugePagesStatus() {
249 | app.HugePagesButton.Text = "Disable HugePages"
250 | app.HugePagesText.Color = Green
251 | } else {
252 | app.HugePagesButton.Text = "Enable HugePages"
253 | app.HugePagesText.Color = Red
254 | }
255 | app.HugePagesButton.Refresh()
256 | app.HugePagesText.Refresh()
257 | }
258 |
259 | func (app *Config) refreshShMemContent() {
260 | app.InfoLog.Println("Refreshing shmem data...")
261 | if getShMemStatus() {
262 | app.ShMemButton.Text = "Disable Shared Memory in THP"
263 | app.ShMemText.Color = Green
264 | } else {
265 | app.ShMemButton.Text = "Enable Shared Memory in THP"
266 | app.ShMemText.Color = Red
267 | }
268 | app.ShMemButton.Refresh()
269 | app.ShMemText.Refresh()
270 |
271 | }
272 |
273 | func (app *Config) refreshCompactionProactivenessContent() {
274 | app.InfoLog.Println("Refreshing compaction proactiveness data...")
275 | if getCompactionProactivenessStatus() {
276 | app.CompactionProactivenessButton.Text = "Revert Compaction Proactiveness"
277 | app.CompactionProactivenessText.Color = Green
278 | } else {
279 | app.CompactionProactivenessButton.Text = "Set Compaction Proactiveness"
280 | app.CompactionProactivenessText.Color = Red
281 | }
282 | app.CompactionProactivenessButton.Refresh()
283 | app.CompactionProactivenessText.Refresh()
284 | }
285 |
286 | func (app *Config) refreshDefragContent() {
287 | app.InfoLog.Println("Refreshing defragmentation data...")
288 | if getDefragStatus() {
289 | app.DefragButton.Text = "Enable Huge Page Defragmentation"
290 | app.DefragText.Color = Green
291 | } else {
292 | app.DefragButton.Text = "Disable Huge Page Defragmentation"
293 | app.DefragText.Color = Red
294 | }
295 | app.DefragButton.Refresh()
296 | app.DefragText.Refresh()
297 | }
298 |
299 | func (app *Config) refreshPageLockUnfairnessContent() {
300 | app.InfoLog.Println("Refreshing page lock unfairness data...")
301 | if getPageLockUnfairnessStatus() {
302 | app.PageLockUnfairnessButton.Text = "Revert Page Lock Unfairness"
303 | app.PageLockUnfairnessText.Color = Green
304 | } else {
305 | app.PageLockUnfairnessButton.Text = "Set Page Lock Unfairness"
306 | app.PageLockUnfairnessText.Color = Red
307 | }
308 | app.PageLockUnfairnessButton.Refresh()
309 | app.PageLockUnfairnessText.Refresh()
310 | }
311 |
312 | func (app *Config) refreshVRAMContent() {
313 | app.InfoLog.Println("Refreshing VRAM data...")
314 | vram, err := getVRAMValue()
315 | if err != nil || vram == 0 {
316 | CryoUtils.ErrorLog.Println(err)
317 | vramStr := fmt.Sprintf("Current VRAM: Unknown")
318 | app.VRAMText.Text = vramStr
319 | app.VRAMText.Color = Gray
320 | } else {
321 | humanVRAMSize := getHumanVRAMSize(vram)
322 | vramStr := fmt.Sprintf("Current VRAM: %s", humanVRAMSize)
323 | app.VRAMText.Text = vramStr
324 | if vram == RecommendedVRAM {
325 | app.VRAMText.Color = Green
326 | } else {
327 | app.VRAMText.Color = Red
328 | }
329 | }
330 |
331 | app.VRAMText.Refresh()
332 | }
333 |
334 | func (app *Config) refreshAllContent() {
335 | app.refreshSwapContent()
336 | app.refreshSwappinessContent()
337 | app.refreshHugePagesContent()
338 | app.refreshCompactionProactivenessContent()
339 | app.refreshShMemContent()
340 | app.refreshDefragContent()
341 | app.refreshPageLockUnfairnessContent()
342 | app.refreshVRAMContent()
343 | }
344 |
--------------------------------------------------------------------------------
/internal/ui_tab.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "fyne.io/fyne/v2"
21 | "fyne.io/fyne/v2/canvas"
22 | "fyne.io/fyne/v2/container"
23 | "fyne.io/fyne/v2/dialog"
24 | "fyne.io/fyne/v2/widget"
25 | "strconv"
26 | "strings"
27 | )
28 |
29 | // Home tab for "recommended" and "default" buttons
30 | func (app *Config) homeTab() *fyne.Container {
31 | welcomeText := canvas.NewText("Welcome to CryoUtilities!", White)
32 | welcomeText.TextSize = HeaderTextSize
33 | welcomeText.TextStyle.Bold = true
34 |
35 | subheadingText := canvas.NewText("Quick settings. Use the tabs at the top of the window to use "+
36 | "settings individually.", White)
37 | subheadingText.TextSize = SubHeadingTextSize
38 |
39 | availableSpace, err := getFreeSpace("/home")
40 | if err != nil {
41 | presentErrorInUI(err, app.MainWindow)
42 | }
43 | var chosenSize string
44 | if availableSpace < RecommendedSwapSizeBytes {
45 | availableSizes, _ := getAvailableSwapSizes()
46 | chosenSize = strings.Fields(availableSizes[len(availableSizes)-1])[0]
47 | } else {
48 | chosenSize = strconv.Itoa(RecommendedSwapSize)
49 | }
50 |
51 | actionText := widget.NewLabel(
52 | "Swap: " + chosenSize + "GB\n" +
53 | "Swappiness: " + RecommendedSwappiness + "\n" +
54 | "HugePages: Enabled\n" +
55 | "Compaction Proactivenes: " + RecommendedCompactionProactiveness + "\n" +
56 | "HugePage Defragmentation: Disabled\n" +
57 | "Page Lock Unfairness: " + RecommendedPageLockUnfairness + "\n" +
58 | "Shared Memory in Huge Pages: Enabled")
59 |
60 | recommendedButton := widget.NewButton("Recommended", func() {
61 | progressGroup := container.NewVBox(
62 | canvas.NewText("Applying recommended settings...", White),
63 | actionText,
64 | widget.NewProgressBarInfinite())
65 | modal := widget.NewModalPopUp(progressGroup, CryoUtils.MainWindow.Canvas())
66 | modal.Show()
67 | renewSudoAuth()
68 | err := UseRecommendedSettings()
69 | if err != nil {
70 | presentErrorInUI(err, CryoUtils.MainWindow)
71 | }
72 | modal.Hide()
73 | app.refreshAllContent()
74 | dialog.ShowInformation(
75 | "Success!",
76 | "Recommended settings applied!",
77 | CryoUtils.MainWindow,
78 | )
79 | })
80 | stockButton := widget.NewButton("Stock", func() {
81 | progressText := canvas.NewText("Reverting to stock settings...", White)
82 | progressBar := widget.NewProgressBarInfinite()
83 | progressGroup := container.NewVBox(progressText, progressBar)
84 | modal := widget.NewModalPopUp(progressGroup, CryoUtils.MainWindow.Canvas())
85 | modal.Show()
86 | renewSudoAuth()
87 | err := UseStockSettings()
88 | if err != nil {
89 | presentErrorInUI(err, CryoUtils.MainWindow)
90 | }
91 | modal.Hide()
92 | app.refreshAllContent()
93 | dialog.ShowInformation(
94 | "Success!",
95 | "Stock settings applied!",
96 | CryoUtils.MainWindow,
97 | )
98 | })
99 |
100 | recommendedSettings := widget.NewCard("Recommended Settings", "Set all settings to "+
101 | "CryoByte33's recommendations.", recommendedButton)
102 | stockSettings := widget.NewCard("Stock Settings", "Reset all settings to Valve defaults, excludes "+
103 | "'Game Data' tab/locations.", stockButton)
104 |
105 | homeVBox := container.NewVBox(
106 | welcomeText,
107 | subheadingText,
108 | recommendedSettings,
109 | stockSettings,
110 | )
111 | app.HomeContainer = homeVBox
112 |
113 | return homeVBox
114 | }
115 |
116 | // Swap tab for all swap-related tasks.
117 | func (app *Config) swapTab() *fyne.Container {
118 | app.SwapText = canvas.NewText("Swap File Size: Unknown", Gray)
119 | app.SwappinessText = canvas.NewText("Swappiness: Unknown", Gray)
120 | // Main content including buttons to resize swap and change swappiness
121 | swapResizeButton := widget.NewButton("Resize", func() {
122 | swapSizeWindow()
123 | app.refreshSwapContent()
124 | })
125 | swappinessChangeButton := widget.NewButton("Change", func() {
126 | swappinessWindow()
127 | app.refreshSwappinessContent()
128 | })
129 |
130 | swapCard := widget.NewCard("Swap File", "Resize the swap file.", swapResizeButton)
131 | swappinessCard := widget.NewCard("Swappiness", "Change the swappiness value.", swappinessChangeButton)
132 |
133 | // Swap info gathering
134 | app.refreshSwapContent()
135 | app.refreshSwappinessContent()
136 |
137 | app.SwapBar = container.NewGridWithColumns(2,
138 | container.NewCenter(app.SwapText),
139 | container.NewCenter(app.SwappinessText))
140 |
141 | topBar := container.NewVBox(
142 | container.NewGridWithRows(1),
143 | container.NewGridWithRows(1, container.NewCenter(canvas.NewText("Current Swap Status:", White))),
144 | app.SwapBar,
145 | )
146 |
147 | swapVBox := container.NewVBox(
148 | swapCard,
149 | swappinessCard,
150 | )
151 |
152 | full := container.NewBorder(topBar, nil, nil, nil, swapVBox)
153 |
154 | return full
155 | }
156 |
157 | // Game Data tab to move and delete prefixes and shadercache.
158 | func (app *Config) storageTab() *fyne.Container {
159 | // These can take a minute to come up, so create a loading bar to show things are happening.
160 | syncDataButton := widget.NewButton("Sync", func() {
161 | progressText := canvas.NewText("Calculating device status...", White)
162 | progressBar := widget.NewProgressBarInfinite()
163 | progressGroup := container.NewVBox(progressText, progressBar)
164 | modal := widget.NewModalPopUp(progressGroup, CryoUtils.MainWindow.Canvas())
165 | modal.Show()
166 | syncGameDataWindow()
167 | modal.Hide()
168 | })
169 | cleanupDataButton := widget.NewButton("Clean", func() {
170 | progressText := canvas.NewText("Calculating device status...", White)
171 | progressBar := widget.NewProgressBarInfinite()
172 | progressGroup := container.NewVBox(progressText, progressBar)
173 | modal := widget.NewModalPopUp(progressGroup, CryoUtils.MainWindow.Canvas())
174 | modal.Show()
175 | cleanupDataWindow()
176 | modal.Hide()
177 | })
178 |
179 | syncData := widget.NewCard("Sync Game Data", "Sync prefix and shaders to the device where the game "+
180 | "is installed", syncDataButton)
181 | cleanStaleData := widget.NewCard("Delete Game Data", "Delete prefixes and shaders for selected games.",
182 | cleanupDataButton)
183 |
184 | gameDataVBox := container.NewVBox(
185 | syncData,
186 | cleanStaleData,
187 | )
188 | app.GameDataContainer = gameDataVBox
189 |
190 | return gameDataVBox
191 | }
192 |
193 | // Tab for non-swap, memory-related tweaks.
194 | func (app *Config) memoryTab() *fyne.Container {
195 | app.HugePagesText = canvas.NewText("Huge Pages (THP)", Red)
196 | app.ShMemText = canvas.NewText("Shared Memory in THP", Red)
197 | app.CompactionProactivenessText = canvas.NewText("Compaction Proactiveness", Red)
198 | app.DefragText = canvas.NewText("Defrag", Red)
199 | app.PageLockUnfairnessText = canvas.NewText("Page Lock Unfairness", Red)
200 |
201 | CryoUtils.HugePagesButton = widget.NewButton("Enable HugePages", func() {
202 | renewSudoAuth()
203 | err := ToggleHugePages()
204 | if err != nil {
205 | presentErrorInUI(err, CryoUtils.MainWindow)
206 | }
207 | app.refreshHugePagesContent()
208 | })
209 |
210 | CryoUtils.ShMemButton = widget.NewButton("Enable Shared Memory in THP", func() {
211 | renewSudoAuth()
212 | err := ToggleShMem()
213 | if err != nil {
214 | presentErrorInUI(err, CryoUtils.MainWindow)
215 | }
216 | app.refreshShMemContent()
217 | })
218 |
219 | CryoUtils.CompactionProactivenessButton = widget.NewButton("Set Compaction Proactiveness", func() {
220 | renewSudoAuth()
221 | err := ToggleCompactionProactiveness()
222 | if err != nil {
223 | presentErrorInUI(err, CryoUtils.MainWindow)
224 | }
225 | app.refreshCompactionProactivenessContent()
226 | })
227 |
228 | CryoUtils.DefragButton = widget.NewButton("Disable Huge Page Defragmentation", func() {
229 | renewSudoAuth()
230 | err := ToggleDefrag()
231 | if err != nil {
232 | presentErrorInUI(err, CryoUtils.MainWindow)
233 | }
234 | app.refreshDefragContent()
235 | })
236 |
237 | CryoUtils.PageLockUnfairnessButton = widget.NewButton("Set Page Lock Unfairness", func() {
238 | renewSudoAuth()
239 | err := TogglePageLockUnfairness()
240 | if err != nil {
241 | presentErrorInUI(err, CryoUtils.MainWindow)
242 | }
243 | app.refreshPageLockUnfairnessContent()
244 | })
245 |
246 | app.refreshHugePagesContent()
247 | app.refreshCompactionProactivenessContent()
248 | app.refreshShMemContent()
249 | app.refreshDefragContent()
250 | app.refreshPageLockUnfairnessContent()
251 |
252 | app.MemoryBar = container.NewGridWithColumns(5,
253 | container.NewCenter(app.HugePagesText),
254 | container.NewCenter(app.ShMemText),
255 | container.NewCenter(app.CompactionProactivenessText),
256 | container.NewCenter(app.DefragText),
257 | container.NewCenter(app.PageLockUnfairnessText))
258 | topBar := container.NewVBox(
259 | container.NewGridWithRows(1),
260 | container.NewGridWithRows(1, container.NewCenter(canvas.NewText("Current Tweak Status:", White))),
261 | app.MemoryBar,
262 | )
263 |
264 | hugePagesCard := widget.NewCard("Huge Pages", "Toggle huge pages", app.HugePagesButton)
265 | shMemCard := widget.NewCard("Shared Memory in THP", "Toggle shared memory in THP", app.ShMemButton)
266 | compactionProactivenessCard := widget.NewCard("Compaction Proactiveness", "Set compaction proactiveness", app.CompactionProactivenessButton)
267 | defragCard := widget.NewCard("Huge Page Defragmentation", "Toggle huge page defragmentation", app.DefragButton)
268 | pageLockUnfairnessCard := widget.NewCard("Page Lock Unfairness", "Set page lock unfairness", app.PageLockUnfairnessButton)
269 |
270 | memoryVBox := container.NewVBox(
271 | hugePagesCard,
272 | shMemCard,
273 | compactionProactivenessCard,
274 | defragCard,
275 | pageLockUnfairnessCard,
276 | )
277 | scroll := container.NewScroll(memoryVBox)
278 | full := container.NewBorder(topBar, nil, nil, nil, scroll)
279 |
280 | return full
281 | }
282 |
283 | func (app *Config) vramTab() *fyne.Container {
284 | app.VRAMText = canvas.NewText("Current VRAM size: Unknown", Gray)
285 |
286 | // Get VRAM value
287 | app.refreshVRAMContent()
288 |
289 | textHowTo := widget.NewLabel("1. Turn off the Steam Deck\n\n" +
290 | "2. Press and hold the volume up button, press the power button, then release both\n\n" +
291 | "3. Navigate to Setup Utility -> Advanced -> UMA Frame Buffer Size")
292 |
293 | textRecommended := widget.NewLabelWithStyle("4G is the recommended setting for most situations", fyne.TextAlignLeading, fyne.TextStyle{Bold: true})
294 | textWarning := widget.NewLabel("Please be aware that some games (RDR2) may experience degraded performance.")
295 |
296 |
297 | textVBox := container.NewVBox(
298 | textHowTo,
299 | textRecommended,
300 | textWarning,
301 | )
302 |
303 | vramCard := widget.NewCard("Minimum VRAM", "How to change the minimum VRAM:", textVBox)
304 |
305 | vramBAR := container.NewGridWithColumns(1,
306 | container.NewCenter(app.VRAMText))
307 | topBar := container.NewVBox(
308 | container.NewGridWithRows(1),
309 | container.NewGridWithRows(1, container.NewCenter(canvas.NewText("Current Tweak Status:", White))),
310 | vramBAR,
311 | )
312 |
313 | vramVBOX := container.NewVBox(
314 | vramCard,
315 | )
316 | scroll := container.NewScroll(vramVBOX)
317 | full := container.NewBorder(topBar, nil, nil, nil, scroll)
318 |
319 | return full
320 | }
321 |
--------------------------------------------------------------------------------
/internal/handler_game_data.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "fmt"
21 | "os"
22 | "path/filepath"
23 | "strconv"
24 |
25 | cp "github.com/otiai10/copy"
26 | )
27 |
28 | type StorageStatus struct {
29 | LeftCompatDirectories []string
30 | LeftShaderDirectories []string
31 | RightCompatDirectories []string
32 | RightShaderDirectories []string
33 | }
34 |
35 | type DataToMove struct {
36 | right []string
37 | left []string
38 | rightSize int64
39 | leftSize int64
40 | }
41 |
42 | // Get a list of the directories inside the provided directory, ignoring symbolic links
43 | func getDirectoryList(path string, includeSymlinks bool) ([]string, error) {
44 | var folderList []string
45 | // Get a list of all files in directory
46 | files, err := os.ReadDir(path)
47 | if err != nil {
48 | CryoUtils.ErrorLog.Println("Unable to list files in", path)
49 | return nil, err
50 | }
51 |
52 | for _, file := range files {
53 | // ui.CryoUtils.InfoLog.Println(file.Name())
54 | // Create a full path with the file and path names
55 | fullPath := filepath.Join(path, file.Name())
56 | if !includeSymlinks {
57 | // If the file is a directory AND is NOT a symlink, append the name of the folder to the list
58 | if file.IsDir() && !isSymbolicLink(fullPath) {
59 | folderList = append(folderList, file.Name())
60 | }
61 | } else {
62 | if file.IsDir() {
63 | folderList = append(folderList, file.Name())
64 | }
65 | }
66 | }
67 |
68 | return folderList, nil
69 | }
70 |
71 | // Update instance of StorageStatus with the current listings of directories.
72 | func (s *StorageStatus) getStorageStatus(left string, right string) error {
73 | var err error
74 | if left == SteamDataRoot {
75 | s.LeftCompatDirectories, err = getDirectoryList(SteamCompatRoot, false)
76 | if err != nil {
77 | return err
78 | }
79 | s.LeftShaderDirectories, err = getDirectoryList(SteamShaderRoot, false)
80 | if err != nil {
81 | return err
82 | }
83 | } else {
84 | compat := filepath.Join(left, ExternalCompatRoot)
85 | shader := filepath.Join(left, ExternalShaderRoot)
86 | // Create the directories if they don't exist already
87 | _ = os.MkdirAll(compat, 0777)
88 | _ = os.MkdirAll(shader, 0777)
89 | s.LeftCompatDirectories, err = getDirectoryList(compat, false)
90 | if err != nil {
91 | return err
92 | }
93 | s.LeftShaderDirectories, err = getDirectoryList(shader, false)
94 | if err != nil {
95 | return err
96 | }
97 | }
98 |
99 | if right == SteamDataRoot {
100 | s.RightCompatDirectories, err = getDirectoryList(SteamCompatRoot, false)
101 | if err != nil {
102 | return err
103 | }
104 | s.RightShaderDirectories, err = getDirectoryList(SteamShaderRoot, false)
105 | if err != nil {
106 | return err
107 | }
108 | } else {
109 | compat := filepath.Join(right, ExternalCompatRoot)
110 | shader := filepath.Join(right, ExternalShaderRoot)
111 | // Create the directories if they don't exist already
112 | _ = os.MkdirAll(compat, 0777)
113 | _ = os.MkdirAll(shader, 0777)
114 | s.RightCompatDirectories, err = getDirectoryList(compat, false)
115 | if err != nil {
116 | return err
117 | }
118 | s.RightShaderDirectories, err = getDirectoryList(shader, false)
119 | if err != nil {
120 | return err
121 | }
122 | }
123 | return nil
124 | }
125 |
126 | func (d *DataToMove) getSpaceNeeded(left string, right string) {
127 | var leftCompat, rightCompat, leftShader, rightShader string
128 | if left == SteamDataRoot {
129 | leftCompat = SteamCompatRoot
130 | leftShader = SteamShaderRoot
131 | } else {
132 | leftCompat = filepath.Join(left, ExternalCompatRoot)
133 | leftShader = filepath.Join(left, ExternalShaderRoot)
134 | }
135 |
136 | if right == SteamDataRoot {
137 | rightCompat = SteamCompatRoot
138 | rightShader = SteamShaderRoot
139 | } else {
140 | rightCompat = filepath.Join(right, ExternalCompatRoot)
141 | rightShader = filepath.Join(right, ExternalShaderRoot)
142 | }
143 |
144 | for x := range d.left {
145 | d.leftSize += getDirectorySize(filepath.Join(leftCompat, d.left[x]))
146 | d.leftSize += getDirectorySize(filepath.Join(leftShader, d.left[x]))
147 | }
148 |
149 | for x := range d.right {
150 | d.rightSize += getDirectorySize(filepath.Join(rightCompat, d.right[x]))
151 | d.rightSize += getDirectorySize(filepath.Join(rightShader, d.right[x]))
152 | }
153 | }
154 |
155 | // Populate a DataToMove object with the current queue of data needing to be moved.
156 | func (d *DataToMove) getDataToMove(left string, right string) error {
157 | libraries, err := findDataFolders()
158 | if err != nil {
159 | return err
160 | }
161 | storage := new(StorageStatus)
162 | err = storage.getStorageStatus(left, right)
163 | if err != nil {
164 | return err
165 | }
166 |
167 | for i := range libraries {
168 | if isSubPath(left, libraries[i].Path) {
169 | CryoUtils.InfoLog.Println("Library location selected as left:", libraries[i].Path)
170 | // If the library is in the left-side parent directory
171 | for _, game := range libraries[i].InstalledGames {
172 | gameString := strconv.Itoa(game)
173 | CryoUtils.InfoLog.Println("Library contains:", gameString)
174 | // If game has files on the right side
175 | if contains(storage.RightCompatDirectories, gameString) && contains(storage.RightShaderDirectories, gameString) {
176 | d.right = append(d.right, gameString)
177 | }
178 | }
179 | } else if isSubPath(right, libraries[i].Path) {
180 | CryoUtils.InfoLog.Println("Library location selected as right:", libraries[i].Path)
181 | // If the library is in the right-side parent directory
182 | for _, game := range libraries[i].InstalledGames {
183 | gameString := strconv.Itoa(game)
184 | CryoUtils.InfoLog.Println("Library contains:", gameString)
185 | // If game is installed on the right side AND has files on the left side
186 | if contains(storage.LeftCompatDirectories, gameString) && contains(storage.LeftShaderDirectories, gameString) {
187 | d.left = append(d.left, gameString)
188 | }
189 | }
190 | } else {
191 | CryoUtils.InfoLog.Println("Library location not selected, skipping:", libraries[i].Path)
192 | }
193 | }
194 | return nil
195 | }
196 |
197 | // Move game data between each location as necessary
198 | func moveGameData(data DataToMove, left string, right string) error {
199 | var progressPerMove = 1.0 / float64(len(data.right)+len(data.left))
200 | var leftCompatPath, leftShaderPath, rightCompatPath, rightShaderPath string
201 |
202 | if left == SteamDataRoot {
203 | leftCompatPath = SteamCompatRoot
204 | leftShaderPath = SteamShaderRoot
205 | } else {
206 | leftCompatPath = filepath.Join(left, ExternalCompatRoot)
207 | leftShaderPath = filepath.Join(left, ExternalShaderRoot)
208 | }
209 |
210 | if right == SteamDataRoot {
211 | rightCompatPath = SteamCompatRoot
212 | rightShaderPath = SteamShaderRoot
213 | } else {
214 | rightCompatPath = filepath.Join(right, ExternalCompatRoot)
215 | rightShaderPath = filepath.Join(right, ExternalShaderRoot)
216 | }
217 |
218 | // Moving to the left
219 | for _, directory := range data.right {
220 | leftCompatDir := filepath.Join(leftCompatPath, directory)
221 | leftShaderDir := filepath.Join(leftShaderPath, directory)
222 | rightCompatDir := filepath.Join(rightCompatPath, directory)
223 | rightShaderDir := filepath.Join(rightShaderPath, directory)
224 |
225 | // Remove any symlinks on the SSD in preparation for either moving to the SSD, or creating new symlinks
226 | steamCompatDir := filepath.Join(SteamCompatRoot, directory)
227 | if isSymbolicLink(steamCompatDir) {
228 | _ = os.Remove(steamCompatDir)
229 | }
230 | steamShaderDir := filepath.Join(SteamShaderRoot, directory)
231 | if isSymbolicLink(steamShaderDir) {
232 | _ = os.Remove(steamShaderDir)
233 | }
234 |
235 | // Copy the files
236 | CryoUtils.InfoLog.Println("Moving " + directory + " left...")
237 | err := cp.Copy(rightCompatDir, leftCompatDir)
238 | if err != nil {
239 | CryoUtils.ErrorLog.Println(err)
240 | return err
241 | }
242 | err = cp.Copy(rightShaderDir, leftShaderDir)
243 | if err != nil {
244 | CryoUtils.ErrorLog.Println(err)
245 | return err
246 | }
247 |
248 | // Remove the old files on the right
249 | CryoUtils.InfoLog.Println("Removing old " + rightCompatDir)
250 | err = os.RemoveAll(rightCompatDir)
251 | if err != nil {
252 | CryoUtils.ErrorLog.Println(err)
253 | return err
254 | }
255 | waitForDeletion(rightCompatPath, directory)
256 | CryoUtils.InfoLog.Println("Removing old " + rightShaderDir)
257 | err = os.RemoveAll(rightShaderDir)
258 | if err != nil {
259 | CryoUtils.ErrorLog.Println(err)
260 | return err
261 | }
262 | waitForDeletion(rightShaderPath, directory)
263 |
264 | // If the destination is NOT on the SSD, make symlinks
265 | if leftCompatPath != SteamCompatRoot {
266 | // Create symlinks on the SSD to the new location
267 | CryoUtils.InfoLog.Println("Creating symlink to new path on SSD...")
268 | err = os.Symlink(leftCompatDir, filepath.Join(SteamCompatRoot, directory))
269 | if err != nil {
270 | CryoUtils.ErrorLog.Println(err)
271 | return err
272 | }
273 | err = os.Symlink(leftShaderDir, filepath.Join(SteamShaderRoot, directory))
274 | if err != nil {
275 | CryoUtils.ErrorLog.Println(err)
276 | return err
277 | }
278 | }
279 |
280 | CryoUtils.MoveDataProgressBar.SetValue(CryoUtils.MoveDataProgressBar.Value + progressPerMove)
281 | }
282 |
283 | // Moving to the right
284 | for _, directory := range data.left {
285 | leftCompatDir := filepath.Join(leftCompatPath, directory)
286 | leftShaderDir := filepath.Join(leftShaderPath, directory)
287 | rightCompatDir := filepath.Join(rightCompatPath, directory)
288 | rightShaderDir := filepath.Join(rightShaderPath, directory)
289 |
290 | // Remove any symlinks on the SSD in preparation for either moving to the SSD, or creating new symlinks
291 | steamCompatDir := filepath.Join(SteamCompatRoot, directory)
292 | if isSymbolicLink(steamCompatDir) {
293 | _ = os.Remove(steamCompatDir)
294 | }
295 | steamShaderDir := filepath.Join(SteamShaderRoot, directory)
296 | if isSymbolicLink(steamShaderDir) {
297 | _ = os.Remove(steamShaderDir)
298 | }
299 |
300 | // Copy the files
301 | CryoUtils.InfoLog.Println("Moving " + directory + " right...")
302 | err := cp.Copy(leftCompatDir, rightCompatDir)
303 | if err != nil {
304 | CryoUtils.ErrorLog.Println(err)
305 | return err
306 | }
307 | err = cp.Copy(leftShaderDir, rightShaderDir)
308 | if err != nil {
309 | CryoUtils.ErrorLog.Println(err)
310 | return err
311 | }
312 |
313 | // Remove the old files on the left
314 | CryoUtils.InfoLog.Println("Removing old " + leftCompatDir)
315 | err = os.RemoveAll(leftCompatDir)
316 | if err != nil {
317 | CryoUtils.ErrorLog.Println(err)
318 | return err
319 | }
320 | waitForDeletion(leftCompatPath, directory)
321 | CryoUtils.InfoLog.Println("Removing old " + leftShaderDir)
322 | err = os.RemoveAll(leftShaderDir)
323 | if err != nil {
324 | CryoUtils.ErrorLog.Println(err)
325 | return err
326 | }
327 | waitForDeletion(leftShaderPath, directory)
328 |
329 | // If the destination is NOT on the SSD, make symlinks
330 | if rightCompatPath != SteamCompatRoot {
331 | // Create symlinks on the SSD to the new location
332 | CryoUtils.InfoLog.Println("Creating symlink to new path on SSD...")
333 | err = os.Symlink(rightCompatDir, filepath.Join(SteamCompatRoot, directory))
334 | if err != nil {
335 | CryoUtils.ErrorLog.Println(err)
336 | return err
337 | }
338 | err = os.Symlink(rightShaderDir, filepath.Join(SteamShaderRoot, directory))
339 | if err != nil {
340 | CryoUtils.ErrorLog.Println(err)
341 | return err
342 | }
343 | }
344 | CryoUtils.MoveDataProgressBar.SetValue(CryoUtils.MoveDataProgressBar.Value + progressPerMove)
345 | }
346 | return nil
347 | }
348 |
349 | // Confirm that all directories are in the proper locations post-move.
350 | func (d *DataToMove) confirmDirectoryStatus(left string, right string) (bool, error) {
351 | var unmoved []string
352 | var dirs StorageStatus
353 | _ = dirs.getStorageStatus(left, right)
354 |
355 | for _, directory := range d.right {
356 | for _, x := range dirs.RightCompatDirectories {
357 | if x == directory {
358 | unmoved = append(unmoved, directory)
359 | }
360 | }
361 | for _, x := range dirs.RightShaderDirectories {
362 | if x == directory {
363 | unmoved = append(unmoved, directory)
364 | }
365 | }
366 | }
367 |
368 | for _, directory := range d.left {
369 | for _, x := range dirs.LeftCompatDirectories {
370 | if x == directory {
371 | unmoved = append(unmoved, directory)
372 | }
373 | }
374 | for _, x := range dirs.LeftShaderDirectories {
375 | if x == directory {
376 | unmoved = append(unmoved, directory)
377 | }
378 | }
379 | }
380 |
381 | if len(unmoved) == 0 {
382 | return true, nil
383 | } else {
384 | return false, fmt.Errorf("the following directories remain in the incorrect locations:\n"+
385 | "%s", unmoved)
386 | }
387 | }
388 |
389 | func getUninstalledGamesData() (uninstalled []string) {
390 |
391 | localGames, err := getLocalGameList()
392 | if err != nil {
393 | return nil
394 | }
395 |
396 | for key, game := range localGames {
397 | if key != 0 && key <= SteamGameMaxInteger && !game.IsInstalled {
398 | uninstalled = append(uninstalled, strconv.Itoa(key))
399 | }
400 | }
401 |
402 | return uninstalled
403 |
404 | }
405 |
--------------------------------------------------------------------------------
/internal/ui_window.go:
--------------------------------------------------------------------------------
1 | // CryoUtilities
2 | // Copyright (C) 2023 CryoByte33 and contributors to the CryoUtilities project
3 |
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 |
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 |
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see .
16 |
17 | package internal
18 |
19 | import (
20 | "fmt"
21 | "strconv"
22 | "strings"
23 |
24 | "fyne.io/fyne/v2"
25 | "fyne.io/fyne/v2/canvas"
26 | "fyne.io/fyne/v2/container"
27 | "fyne.io/fyne/v2/dialog"
28 | "fyne.io/fyne/v2/widget"
29 | )
30 |
31 | func syncGameDataWindow() {
32 | var selectionContainer *fyne.Container
33 | // Create a new window
34 | w := CryoUtils.App.NewWindow("Sync Game Data")
35 |
36 | driveList, err := getListOfAttachedDrives()
37 | if err != nil {
38 | presentErrorInUI(err, w)
39 | }
40 |
41 | if len(driveList) > 1 {
42 | // Place a prompt near the top of the window
43 | prompt := canvas.NewText("Please select the devices you'd like to sync data between.", nil)
44 | prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}
45 |
46 | // Make the list widgets with initial contents, excluding what the other has pre-selected
47 | // This is simply to make it more "one click" for users.
48 | leftList := widget.NewSelect(removeElementFromStringSlice(driveList[1], driveList), func(s string) {})
49 | rightList := widget.NewSelect(removeElementFromStringSlice(driveList[0], driveList), func(s string) {})
50 |
51 | // Pre-define each direction with the default values
52 | leftSelected := removeElementFromStringSlice(driveList[1], driveList)[0]
53 | leftList.Selected = leftSelected
54 | rightSelected := removeElementFromStringSlice(driveList[0], driveList)[0]
55 | rightList.Selected = rightSelected
56 | // Define the OnChanged functions after, so both are aware of the other's existence.
57 | leftList.OnChanged = func(s string) {
58 | leftSelected = s
59 | // Remove the selected option from the other list to prevent both sides being the same.
60 | rightList.Options = removeElementFromStringSlice(s, driveList)
61 | }
62 | rightList.OnChanged = func(s string) {
63 | rightSelected = s
64 | // Remove the selected option from the other list to prevent both sides being the same.
65 | leftList.Options = removeElementFromStringSlice(s, driveList)
66 | }
67 |
68 | cancelButton := widget.NewButton("Cancel", func() {
69 | w.Close()
70 | })
71 | submitButton := widget.NewButton("Submit", func() {
72 | selectionContainer.Hide()
73 | w.CenterOnScreen()
74 | populateGameDataWindow(w, leftSelected, rightSelected)
75 | })
76 | buttonBar := container.NewHSplit(cancelButton, submitButton)
77 | selectionContainer = container.NewVBox(prompt, leftList, rightList, buttonBar)
78 | } else {
79 | // Place a prompt near the top of the window
80 | prompt := canvas.NewText("Not enough drives attached to sync data", Red)
81 | prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}
82 |
83 | cancelButton := widget.NewButton("Cancel", func() {
84 | w.Close()
85 | })
86 |
87 | selectionContainer = container.NewVBox(prompt, cancelButton)
88 | }
89 |
90 | w.SetContent(selectionContainer)
91 | w.CenterOnScreen()
92 | w.RequestFocus()
93 | w.Show()
94 | }
95 |
96 | func populateGameDataWindow(w fyne.Window, left string, right string) {
97 | var leftCard, rightCard *widget.Card
98 | var syncDataButton *widget.Button
99 | var data DataToMove
100 |
101 | p := widget.NewProgressBarInfinite()
102 | d := dialog.NewCustom("Finding data to move...", "Dismiss", p, w)
103 | d.Show()
104 |
105 | // Get a list of data to move
106 | err := data.getDataToMove(left, right)
107 | if err != nil {
108 | CryoUtils.ErrorLog.Println(err)
109 | d.Hide()
110 | presentErrorInUI(err, w)
111 | }
112 |
113 | // Get the storage totals necessary for each side
114 | data.getSpaceNeeded(left, right)
115 |
116 | leftSpaceAvailable, err := getFreeSpace(left)
117 | if err != nil {
118 | presentErrorInUI(err, w)
119 | }
120 | rightSpaceAvailable, err := getFreeSpace(right)
121 | if err != nil {
122 | presentErrorInUI(err, w)
123 | }
124 |
125 | // Place a prompt near the top of the window
126 | prompt := canvas.NewText("Please confirm that it is okay to move this data:", nil)
127 | prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}
128 |
129 | // User-presentable strings
130 | leftDataStr := fmt.Sprintf("Data to be moved to %s", right)
131 | leftSizeStr := fmt.Sprintf("Total Size: %.2fGB", float64(data.leftSize)/float64(GigabyteMultiplier))
132 | rightDataStr := fmt.Sprintf("Data to be moved to %s", left)
133 | rightSizeStr := fmt.Sprintf("Total Size: %.2fGB", float64(data.rightSize)/float64(GigabyteMultiplier))
134 |
135 | // Deal with lack of space on left
136 | if leftSpaceAvailable < data.rightSize {
137 | leftCard = widget.NewCard(leftDataStr, "",
138 | canvas.NewText("Error: Not enough space available on destination drive.", Red))
139 | // Provide a button to close the window
140 | syncDataButton = widget.NewButton("Close", func() {
141 | w.Close()
142 | })
143 | }
144 |
145 | // Deal with lack of space on right
146 | if rightSpaceAvailable < data.leftSize {
147 | rightCard = widget.NewCard(rightDataStr, "",
148 | canvas.NewText("Error: Not enough space available on destination drive.", Red))
149 | // Provide a button to close the window
150 | syncDataButton = widget.NewButton("Close", func() {
151 | w.Close()
152 | })
153 | }
154 |
155 | leftList, rightList, err := getDataToMoveUI(data)
156 | // Deal with error
157 | if err != nil {
158 | // Create an error in each card if directories can't be listed
159 | leftCard = widget.NewCard(leftDataStr, "",
160 | canvas.NewText("Error: Failed to get list of directories to be moved.", Red))
161 | rightCard = widget.NewCard(rightDataStr, "",
162 | canvas.NewText("Error: Failed to get list of directories to be moved.", Red))
163 | // Provide a button to close the window
164 | syncDataButton = widget.NewButton("Close", func() {
165 | w.Close()
166 | })
167 | }
168 |
169 | // If there's anything to move left
170 | if len(data.right) != 0 {
171 | leftCard = widget.NewCard(rightDataStr, rightSizeStr, leftList)
172 | } else {
173 | leftCard = widget.NewCard(rightDataStr, "",
174 | canvas.NewText("None! Everything is synced in this direction.", Green))
175 | }
176 |
177 | // If there's anything to move right
178 | if len(data.left) != 0 {
179 | rightCard = widget.NewCard(leftDataStr, leftSizeStr, rightList)
180 | } else {
181 | rightCard = widget.NewCard(leftDataStr, "",
182 | canvas.NewText("None! Everything is synced in this direction.", Green))
183 | }
184 |
185 | // Create button if something can sync
186 | if len(data.right) != 0 || len(data.left) != 0 {
187 | syncDataButton = widget.NewButton("Confirm", func() {
188 | // Do the actual sync
189 | CryoUtils.InfoLog.Println("Sync data confirmed")
190 | progress := widget.NewProgressBar()
191 | CryoUtils.MoveDataProgressBar = progress
192 | progress.Resize(fyne.NewSize(500, 50))
193 | tempVBox := container.NewVBox(canvas.NewText("Moving items, please wait...", nil), progress)
194 | widget.ShowModalPopUp(tempVBox, w.Canvas())
195 | err = moveGameData(data, left, right)
196 | if err != nil {
197 | presentErrorInUI(err, w)
198 | } else {
199 | _, err := data.confirmDirectoryStatus(left, right)
200 | if err != nil {
201 | presentErrorInUI(err, w)
202 | } else {
203 | CryoUtils.InfoLog.Println("All data moved properly, printing success!")
204 | dialog.ShowInformation(
205 | "Success!",
206 | "Data move completed, all game data is synced to the appropriate device.",
207 | CryoUtils.MainWindow,
208 | )
209 | w.Close()
210 | }
211 | }
212 | })
213 | } else {
214 | // Otherwise, provide a button to close the window
215 | syncDataButton = widget.NewButton("Close", func() {
216 | w.Close()
217 | })
218 | }
219 | cancelButton := widget.NewButton("Cancel", func() {
220 | w.Close()
221 | })
222 |
223 | d.Hide()
224 |
225 | // Format the window
226 | syncMain := container.NewGridWithColumns(1, leftCard, rightCard)
227 | syncButtonBorder := container.NewGridWithColumns(2, cancelButton, syncDataButton)
228 | syncLayout := container.NewBorder(nil, syncButtonBorder, nil, nil, syncMain)
229 | w.SetContent(syncLayout)
230 | w.Resize(fyne.NewSize(300, 450))
231 | w.CenterOnScreen()
232 | w.RequestFocus()
233 | w.Show()
234 | }
235 |
236 | func cleanupDataWindow() {
237 | var cleanupCard *widget.Card
238 | var cleanupButton, cancelButton *widget.Button
239 |
240 | // Create a new window
241 | w := CryoUtils.App.NewWindow("Clean Game Data")
242 |
243 | var removeList []string
244 | cleanupList, err := createGameDataList()
245 | if err != nil {
246 | presentErrorInUI(err, CryoUtils.MainWindow)
247 | }
248 | cleanupList.OnChanged = func(s []string) {
249 | var tempList []string
250 |
251 | for i := range s {
252 | // Get only the game ID for the selected games
253 | tempList = append(tempList, strings.Split(s[i], " ")[0])
254 | }
255 | removeList = tempList
256 | }
257 | cleanupScroll := container.NewVScroll(cleanupList)
258 |
259 | // Create an error in each card if directories can't be listed
260 | cleanupCard = widget.NewCard("Clean Stale Game Data",
261 | "Choose which game's prefixes and shadercache you would like to remove.",
262 | cleanupScroll)
263 | cancelButton = widget.NewButton("Cancel", func() {
264 | w.Close()
265 | })
266 | cleanupButton = widget.NewButton("Delete Selected", func() {
267 | dialog.ShowConfirm("Are you sure?", "Are you sure you want to delete these files?\n\n"+
268 | "Please be sure to back up any Non-Steam-Cloud save games before\n"+
269 | "deleting them using this tool, as any selected will be lost.",
270 | func(b bool) {
271 | if b {
272 | possibleLocations, err := getListOfDataAllDataLocations()
273 | if err != nil {
274 | CryoUtils.ErrorLog.Println(err)
275 | presentErrorInUI(err, CryoUtils.MainWindow)
276 | }
277 |
278 | removeGameData(removeList, possibleLocations)
279 |
280 | dialog.ShowInformation(
281 | "Success!",
282 | "Process completed!",
283 | CryoUtils.MainWindow,
284 | )
285 | w.Close()
286 | } else {
287 | w.Close()
288 | }
289 | }, w)
290 | })
291 |
292 | cleanAllUninstalled := widget.NewButton("Delete All Uninstalled", func() {
293 | dialog.ShowConfirm("Are you sure?", "Are you sure you want to delete these files?\n\n"+
294 | "Please be sure to back up any Non-Steam-Cloud save games before\n"+
295 | "deleting them using this tool, as any selected will be lost.",
296 | func(b bool) {
297 | if !b {
298 | w.Close()
299 | }
300 |
301 | locations, err := getListOfDataAllDataLocations()
302 | if err != nil {
303 | CryoUtils.ErrorLog.Println(err)
304 | presentErrorInUI(err, CryoUtils.MainWindow)
305 | }
306 |
307 | removeGameData(getUninstalledGamesData(), locations)
308 |
309 | dialog.ShowInformation(
310 | "Success!",
311 | "Process completed!",
312 | CryoUtils.MainWindow,
313 | )
314 | w.Close()
315 |
316 | }, w)
317 |
318 | })
319 |
320 | // Format the window
321 | cleanupMain := container.NewGridWithColumns(1, cleanupCard)
322 | cleanupButtonsGrid := container.NewGridWithColumns(2, cancelButton, cleanupButton)
323 | extraButtonGrid := container.NewGridWithColumns(1, cleanAllUninstalled)
324 | footerButtons := container.NewGridWithColumns(1, cleanupButtonsGrid, extraButtonGrid)
325 | cleanupLayout := container.NewBorder(nil, footerButtons, nil, nil, cleanupMain)
326 | w.SetContent(cleanupLayout)
327 | w.Resize(fyne.NewSize(300, 450))
328 | w.CenterOnScreen()
329 | w.RequestFocus()
330 | w.Show()
331 | }
332 |
333 | func swapSizeWindow() {
334 | // Create a new window
335 | w := CryoUtils.App.NewWindow("Change Swap Size")
336 |
337 | // Place a prompt near the top of the window
338 | prompt := canvas.NewText("Please choose the new swap file size in gigabytes:", nil)
339 | prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}
340 |
341 | // Determine maximum available space for a swap file and construct a list of available sizes based on it
342 | availableSwapSizes, err := getAvailableSwapSizes()
343 | if err != nil {
344 | presentErrorInUI(err, w)
345 | }
346 |
347 | // Give the user a choice in swap file sizes
348 | var chosenSize int
349 | choice := widget.NewRadioGroup(availableSwapSizes, func(value string) {
350 | // Only grab the number at the beginning of the string, allows for suffixes.
351 | chosenSize, err = strconv.Atoi(strings.Split(value, " ")[0])
352 | if err != nil {
353 | presentErrorInUI(err, w)
354 | }
355 | })
356 |
357 | // Provide a button to submit the choice
358 | swapResizeButton := widget.NewButton("Resize Swap File", func() {
359 | progress := widget.NewProgressBarInfinite()
360 | d := dialog.NewCustom("Resizing Swap File, please be patient..."+
361 | "(This can take up to 30 minutes)", "Quit", progress,
362 | w,
363 | )
364 | d.Show()
365 | err = changeSwapSizeGUI(chosenSize)
366 | if err != nil {
367 | d.Hide()
368 | presentErrorInUI(err, w)
369 | } else {
370 | d.Hide()
371 | dialog.ShowInformation(
372 | "Success!",
373 | "Process completed! You can verify the file is resized by\n"+
374 | "running 'ls -lash /home/swapfile' or 'swapon -s' in Konsole.",
375 | CryoUtils.MainWindow,
376 | )
377 | CryoUtils.refreshSwapContent()
378 | w.Close()
379 | }
380 | })
381 |
382 | // Make a progress bar and hide it
383 | progress := widget.NewProgressBar()
384 | CryoUtils.SwapResizeProgressBar = progress
385 | progress.Hide()
386 |
387 | // Format the window
388 | swapVBox := container.NewVBox(prompt, choice, swapResizeButton)
389 | w.SetContent(swapVBox)
390 | w.Resize(fyne.NewSize(400, 300))
391 | w.CenterOnScreen()
392 | w.RequestFocus()
393 | w.Show()
394 | }
395 |
396 | // Note: Having a separate function for this is hacky, but necessary for progress bar functionality
397 | func changeSwapSizeGUI(size int) error {
398 | // Disable swap temporarily
399 | renewSudoAuth()
400 | CryoUtils.InfoLog.Println("Disabling swap temporarily...")
401 | err := disableSwap()
402 | if err != nil {
403 | return err
404 | }
405 | // Resize the file
406 | renewSudoAuth()
407 | err = resizeSwapFile(size)
408 | if err != nil {
409 | return err
410 | }
411 | // Set permissions on file
412 | renewSudoAuth()
413 | err = setSwapPermissions()
414 | if err != nil {
415 | return err
416 | }
417 | // Initialize new swap file
418 | renewSudoAuth()
419 | err = initNewSwapFile()
420 | if err != nil {
421 | return err
422 | }
423 | return nil
424 | }
425 |
426 | func swappinessWindow() {
427 | // Create a new window
428 | w := CryoUtils.App.NewWindow("Change Swappiness")
429 |
430 | // Place a prompt near the top of the window
431 | prompt := canvas.NewText("Please choose the new swappiness.", nil)
432 | prompt.TextSize, prompt.TextStyle = 18, fyne.TextStyle{Bold: true}
433 |
434 | // Give the user a choice in swap file sizes
435 | var chosenSwappiness string
436 | choice := widget.NewRadioGroup(AvailableSwappinessOptions, func(value string) {
437 | chosenSwappiness = strings.Fields(value)[0]
438 | })
439 |
440 | // Provide a button to submit the choice
441 | swappinessChangeButton := widget.NewButton("Change Swappiness", func() {
442 | renewSudoAuth()
443 | err := ChangeSwappiness(chosenSwappiness)
444 | if err != nil {
445 | presentErrorInUI(err, w)
446 | } else {
447 | dialog.ShowInformation(
448 | "Success!",
449 | "Swappiness change completed!",
450 | CryoUtils.MainWindow,
451 | )
452 | CryoUtils.refreshSwappinessContent()
453 | w.Close()
454 | }
455 | })
456 |
457 | // Format the window
458 | swapVBox := container.NewVBox(prompt, choice, swappinessChangeButton)
459 | w.SetContent(swapVBox)
460 | w.CenterOnScreen()
461 | w.RequestFocus()
462 | w.Show()
463 | }
464 |
--------------------------------------------------------------------------------
/internal/bundled_resources.go:
--------------------------------------------------------------------------------
1 | // auto-generated
2 | // Code generated by '$ fyne bundle'. DO NOT EDIT.
3 |
4 | package internal
5 |
6 | import "fyne.io/fyne/v2"
7 |
8 | var ResourceIconPng = &fyne.StaticResource{
9 | StaticName: "icon.png",
10 | StaticContent: []byte(
11 | "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x96\x00\x00\x00\x96\b\x06\x00\x00\x00<\x01q\xe2\x00\x00\x05ViTXtXML:com.adobe.xmp\x00\x00\x00\x00\x00\n\n \n \n \n \n cryo_logo\n \n \n \n \n \n \n \n \n \n\n\x12(\xa4\xe5\x00\x00\x01\x80iCCPsRGB IEC61966-2.1\x00\x00(\x91u\x91\xcf+DQ\x14\xc7?\x06\x11\xe3G\xb1\xb0\xb0x\t+4FMl\x94\x91P\x92\xc6(\x83\xcd̛_jf\xbc\xde{\x93&[e\xab(\xb1\xf1k\xc1_\xc0VY+E\xa4d)kb\x83\x9esg\xd4L2\xe7v\xee\xf9\xdc\xef\xbd\xe7t\xef\xb9\xe0\n\xa6\xf4\xb4U\xe5\x81t\xc66\x03\xe3~m>\xb4\xa0\xd5<㦕Fz\xe9\x0e\xeb\x961233EY\xfb\xb8\xa3Bś^U\xab\xfc\xb9\x7f\xad>\x1a\xb3t\xa8\xa8\x15\x1e\xd6\r\xd3\x16\x9e\x10\x9eZ\xb5\r\xc5\xdb\u00adz2\x1c\x15>\x15\xee1\xe5\x82·J\x8f\x14\xf8Eq\xa2\xc0_\x8a\xcd``\x14\\\xcd\xc2Z\xa2\x84#%\xac'ʹ\xb0\xbc\x9c\xcet*\xab\xff\xdeG\xbd\xc4\x1d\xc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߉\xe9K\x16\xc5Q\x89\xd8\xfe\xba\xed91?\xea붏v̮\xc7\xf6>\xb6\x9f\x8dy\xef\x7f\xdb\xfe~\xdc{g\x94\x00\x87\xc1r\x7f\xdbKc~\xe4i\xb6\xbf\\\xc0\xfd>k\xfbΘ\xf7\xfa\xd0v\x9d\xc3\xfe`F{\xc0\xf6\xd6\x0euڣ\x18\x1f\xbc\xde\xf6D\xdbk<\x1e\xd8\xf6\x86\xb6\x87\xda~?\xa6\xa8~k{\x87\x12\xbe\x92\x8c4\xb1\xdd\xdb\xf6\xe31?\xfeb\xdb?q\xbe\xc6{#\x9b\a\xd9^\x10\xd3\xe6
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------