From 76b6fb3da636940691b20ad6cba0304420283a7c Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Tue, 22 Oct 2024 03:22:52 +0300 Subject: [PATCH] ci: add desktop files --- .github/workflows/flatpak.yml | 2 +- build/appicon.svg | 33 +++++++++++++++++++ dirs/dirs.go | 10 +++--- flatpak/dev.casraf.StimVisor.appdata.xml | 21 ++++++++++++ flatpak/dev.casraf.StimVisor.desktop | 4 +++ .../dev.casraf.StimVisor.yml | 12 ++++++- steam/games.go | 12 ++++--- 7 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 build/appicon.svg create mode 100644 flatpak/dev.casraf.StimVisor.appdata.xml create mode 100644 flatpak/dev.casraf.StimVisor.desktop rename dev.casraf.StimVisor.yml => flatpak/dev.casraf.StimVisor.yml (72%) diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index faf784d..c0a826f 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -23,7 +23,7 @@ jobs: submodules: 'recursive' - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 with: - manifest-path: dev.casraf.StimVisor.yml + manifest-path: flatpak/dev.casraf.StimVisor.yml cache-key: flatpak-builder-${{ github.sha }} bundle: StimVisor.flatpak # - name: "Add to release" diff --git a/build/appicon.svg b/build/appicon.svg new file mode 100644 index 0000000..7ed30dd --- /dev/null +++ b/build/appicon.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dirs/dirs.go b/dirs/dirs.go index bac9b9b..543fa64 100644 --- a/dirs/dirs.go +++ b/dirs/dirs.go @@ -15,9 +15,11 @@ const ( LINUX_STEAM_DIR = "%s/.steam/steam" ) -const ( - SYNC_APP_ID = 760 -) +var STEAM_INTERNAL_IDS = []string{ + "7", // Steam Config + "760", // Steam Cloud - Screenshots + "241100", // Steam Controller Config +} // GetSteamDirectory returns the Steam directory path based on the operating system. func GetSteamDirectory() (string, error) { @@ -74,8 +76,6 @@ func GetSyncDirectory() (string, error) { return fmt.Sprintf("%s/760", userDir), nil } -var STEAM_INTERNAL_IDS = []string{"7", "760"} - // GetUsersDirectories returns a list of directories for all Steam users. func GetUsersDirectories() ([]string, error) { steamDir, err := GetSteamDirectory() diff --git a/flatpak/dev.casraf.StimVisor.appdata.xml b/flatpak/dev.casraf.StimVisor.appdata.xml new file mode 100644 index 0000000..8180e9c --- /dev/null +++ b/flatpak/dev.casraf.StimVisor.appdata.xml @@ -0,0 +1,21 @@ + + + + dev.casraf.StimVisor + MIT + MIT + StimVisor + A Steam library manager for screenshots, screen captures, save data and more. + +
    +
  • Manage, export and share screenshots or screen captures.
  • +
  • View game information and manage your installation.
  • +
  • Manage your game save data.
  • +
+
+ + Utility + + https://github.com/chenasraf/stimvisor + contact_at_casraf_dot_dev +
diff --git a/flatpak/dev.casraf.StimVisor.desktop b/flatpak/dev.casraf.StimVisor.desktop new file mode 100644 index 0000000..43afa84 --- /dev/null +++ b/flatpak/dev.casraf.StimVisor.desktop @@ -0,0 +1,4 @@ +[Desktop Entry] +Name=StimVisor +Type=Application +Exec=/app/bin/stimvisor diff --git a/dev.casraf.StimVisor.yml b/flatpak/dev.casraf.StimVisor.yml similarity index 72% rename from dev.casraf.StimVisor.yml rename to flatpak/dev.casraf.StimVisor.yml index 1bdfdf3..bab3f5c 100644 --- a/dev.casraf.StimVisor.yml +++ b/flatpak/dev.casraf.StimVisor.yml @@ -53,7 +53,17 @@ modules: buildsystem: simple sources: - type: dir - path: . + path: ../ build-commands: - PATH=$PATH:$GOROOT/bin:$NODEROOT/bin:$GOBIN wails build -ldflags="-X main.Version=0.0.1 -X main.Build=$(date +%FT%T%z)" - install -Dm755 build/bin/stimvisor $FLATPAK_DEST/bin/stimvisor + - desktop-file-edit --set-icon=$FLATPAK_ID flatpak/$FLATPAK_ID.desktop + - install -Dm644 build/appicon.svg /app/share/icons/hicolor/scalable/apps/$FLATPAK_ID.svg + - > + for size in {32,64,128,256}; do + rsvg-convert build/appicon.svg -w "$size" -h "$size" -a -f png -o "$size.png"; + install -Dm644 "$size.png" "/app/share/icons/hicolor/${size}x${size}/apps/$FLATPAK_ID.png"; + done + - install -Dm00644 flatpak/$FLATPAK_ID.desktop $FLATPAK_DEST/share/applications/$FLATPAK_ID.desktop + - install -Dm00644 flatpak/$FLATPAK_ID.appdata.xml $FLATPAK_DEST/share/appdata/$FLATPAK_ID.appdata.xml + diff --git a/steam/games.go b/steam/games.go index 53a50d3..b43df5d 100644 --- a/steam/games.go +++ b/steam/games.go @@ -68,16 +68,12 @@ const STEAM_API_URL = "https://store.steampowered.com/api/appdetails?appids=%s" func FetchGameInfo(gameId string) (map[string]interface{}, error) { cachePath := filepath.Join(GetGameInfoCacheDir(), gameId+".json") url := fmt.Sprintf(STEAM_API_URL, gameId) + fmt.Printf("Fetching game info for %s from %s", gameId, url) resp, err := http.Get(url) if err != nil { panic(err) } defer resp.Body.Close() - cacheFile, err := os.Create(cachePath) - if err != nil { - panic(err) - } - defer cacheFile.Close() respBytes, err := io.ReadAll(resp.Body) respJson := make(map[string]interface{}) @@ -92,6 +88,12 @@ func FetchGameInfo(gameId string) (map[string]interface{}, error) { respGameData := respGame["data"].(map[string]interface{}) partBytes, _ := json.Marshal(respGameData) + cacheFile, err := os.Create(cachePath) + if err != nil { + panic(err) + } + defer cacheFile.Close() + cacheFile.WriteString(string(partBytes)) return respGameData, nil