Skip to content

Commit

Permalink
feat(devtools): add support for MSIX installations (spicetify#1880)
Browse files Browse the repository at this point in the history
* feat(devtools): add support for MSIX installations

* style: use `PrintError`
  • Loading branch information
kyrie25 authored Aug 22, 2022
1 parent 06e9bb5 commit 955f969
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/cmd/devtools.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"log"
"os"
"path/filepath"
"runtime"
"strings"

Expand All @@ -16,7 +17,13 @@ func SetDevTools() {

switch runtime.GOOS {
case "windows":
filePath = os.Getenv("LOCALAPPDATA") + "\\Spotify\\offline.bnk"
appFilePath := os.Getenv("LOCALAPPDATA") + "\\Spotify\\offline.bnk"
if _, err := os.Stat(appFilePath); err == nil {
filePath = appFilePath
} else if len(utils.WinXApp()) != 0 && len(utils.WinXPrefs()) != 0 {
dir, _ := filepath.Split(utils.WinXPrefs())
filePath = filepath.Join(dir, "offline.bnk")
}
case "linux":
{
homePath := os.Getenv("HOME")
Expand All @@ -39,7 +46,8 @@ func SetDevTools() {
}

if _, err := os.Stat(filePath); os.IsNotExist(err) {
log.Fatal("Can't find the offline.bnk file!")
utils.PrintError("Can't find \"offline.bnk\"")
os.Exit(1)
}

file, err := os.OpenFile(filePath, os.O_RDWR, 0644)
Expand Down
10 changes: 5 additions & 5 deletions src/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func FindAppPath() string {
case "windows":
path := winApp()
if len(path) == 0 {
path = winXApp()
path = WinXApp()
}
return path

Expand All @@ -187,8 +187,8 @@ func FindPrefFilePath() string {
switch runtime.GOOS {
case "windows":
path := winPrefs()
if len(path) == 0 && len(winXApp()) != 0 {
path = winXPrefs()
if len(path) == 0 && len(WinXApp()) != 0 {
path = WinXPrefs()
}
if len(path) == 0 {
PrintError("No valid path options found, ensure you have Spotify installed and have ran it for at least 30 seconds.")
Expand Down Expand Up @@ -223,7 +223,7 @@ func winPrefs() string {
return ""
}

func winXApp() string {
func WinXApp() string {
ps, _ := exec.LookPath("powershell.exe")
cmd := exec.Command(ps,
"-NoProfile",
Expand All @@ -238,7 +238,7 @@ func winXApp() string {
return ""
}

func winXPrefs() string {
func WinXPrefs() string {
ps, _ := exec.LookPath("powershell.exe")
cmd := exec.Command(ps,
"-NoProfile",
Expand Down

0 comments on commit 955f969

Please sign in to comment.