Skip to content

Commit

Permalink
fix(block-updates): block update folder on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
rxri committed Sep 9, 2024
1 parent d0c9272 commit 2b46b98
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/cmd/block-updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"bytes"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand All @@ -24,6 +25,30 @@ func BlockSpotifyUpdates(disabled bool) {
spotifyExecPath = filepath.Join(spotifyExecPath, "..", "MacOS", "Spotify")
}

var str, msg string
if runtime.GOOS == "darwin" {
homeDir, err := os.UserHomeDir()
if err != nil {
utils.PrintError("Cannot get user home directory")
return
}
updateDir := homeDir + "/Library/Application Support/Spotify/PersistentCache/Update"
if disabled {
exec.Command("pkill", "Spotify").Run()
exec.Command("mkdir", "-p", updateDir).Run()
exec.Command("chflags", "uchg", updateDir).Run()
msg = "Disabled"
} else {
exec.Command("pkill", "Spotify").Run()
exec.Command("mkdir", "-p", updateDir).Run()
exec.Command("chflags", "nouchg", updateDir).Run()
msg = "Enabled"
}

utils.PrintSuccess(msg + " Spotify updates!")
return
}

file, err := os.OpenFile(spotifyExecPath, os.O_RDWR, 0644)
if err != nil {
utils.Fatal(err)
Expand All @@ -40,7 +65,6 @@ func BlockSpotifyUpdates(disabled bool) {
utils.PrintError("Can't find update endpoint in executable")
return
}
var str, msg string
if disabled {
str = "no/thanks"
msg = "Disabled"
Expand Down

0 comments on commit 2b46b98

Please sign in to comment.