From 3a76f26b0d532038581dcd2edf0ad4f1e46cf92e Mon Sep 17 00:00:00 2001 From: chulo Date: Mon, 24 Feb 2020 14:47:44 -0300 Subject: [PATCH] Darwin build --- internal/lyricfier/server.go | 2 ++ internal/lyricfier/spotify_darwin.go | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/lyricfier/server.go b/internal/lyricfier/server.go index 6bab7b4..26e4013 100644 --- a/internal/lyricfier/server.go +++ b/internal/lyricfier/server.go @@ -5,6 +5,7 @@ import ( "github.com/labstack/echo" "html/template" "io" + "mime" "net/http" "os" ) @@ -30,6 +31,7 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c } func (h *Server) Init(appData *AppData) { + mime.AddExtensionType(".mjs", "application/javascript") h.hub = newHub() go h.hub.run() h.e = echo.New() diff --git a/internal/lyricfier/spotify_darwin.go b/internal/lyricfier/spotify_darwin.go index 415820d..0882129 100644 --- a/internal/lyricfier/spotify_darwin.go +++ b/internal/lyricfier/spotify_darwin.go @@ -2,9 +2,11 @@ package lyricfier import ( + "fmt" "golang.org/x/text/encoding/charmap" - "log" - "os/exec" + "os" + . "os/exec" + "path/filepath" "strings" "time" ) @@ -15,7 +17,7 @@ type Spotify struct { func (h *Spotify) Init() { } func getDataFromAppleScript() (bool, string, string) { - cmd := exec.Command("osascript", "-e", ` + cmd := Command("osascript", "-e", ` tell application "System Events" set processList to (name of every process) end tell @@ -30,7 +32,7 @@ end if out, err := cmd.Output() if err != nil { - log.Fatal(err) + fmt.Println(err, out) return false, "", "" } d := charmap.CodePage850.NewDecoder() @@ -69,7 +71,7 @@ func (h *Spotify) Ticker(changes chan string) { } func GetDbPath() string { - return filepath.join(os.Getenv("HOME"), "/Library/Application Support/lyricfier") + return filepath.Join(os.Getenv("HOME"), "/Library/Application Support/lyricfier") } func GetPlatformName() string {