@@ -3,6 +3,7 @@ package cmd
3
3
import (
4
4
"bytes"
5
5
"os"
6
+ "os/exec"
6
7
"path/filepath"
7
8
"runtime"
8
9
"strings"
@@ -24,6 +25,30 @@ func BlockSpotifyUpdates(disabled bool) {
24
25
spotifyExecPath = filepath .Join (spotifyExecPath , ".." , "MacOS" , "Spotify" )
25
26
}
26
27
28
+ var str , msg string
29
+ if runtime .GOOS == "darwin" {
30
+ homeDir , err := os .UserHomeDir ()
31
+ if err != nil {
32
+ utils .PrintError ("Cannot get user home directory" )
33
+ return
34
+ }
35
+ updateDir := homeDir + "/Library/Application Support/Spotify/PersistentCache/Update"
36
+ if disabled {
37
+ exec .Command ("pkill" , "Spotify" ).Run ()
38
+ exec .Command ("mkdir" , "-p" , updateDir ).Run ()
39
+ exec .Command ("chflags" , "uchg" , updateDir ).Run ()
40
+ msg = "Disabled"
41
+ } else {
42
+ exec .Command ("pkill" , "Spotify" ).Run ()
43
+ exec .Command ("mkdir" , "-p" , updateDir ).Run ()
44
+ exec .Command ("chflags" , "nouchg" , updateDir ).Run ()
45
+ msg = "Enabled"
46
+ }
47
+
48
+ utils .PrintSuccess (msg + " Spotify updates!" )
49
+ return
50
+ }
51
+
27
52
file , err := os .OpenFile (spotifyExecPath , os .O_RDWR , 0644 )
28
53
if err != nil {
29
54
utils .Fatal (err )
@@ -40,7 +65,6 @@ func BlockSpotifyUpdates(disabled bool) {
40
65
utils .PrintError ("Can't find update endpoint in executable" )
41
66
return
42
67
}
43
- var str , msg string
44
68
if disabled {
45
69
str = "no/thanks"
46
70
msg = "Disabled"
0 commit comments