diff --git a/artwork/icon.png b/artwork/icon.png
new file mode 100644
index 0000000..467a58d
Binary files /dev/null and b/artwork/icon.png differ
diff --git a/artwork/icon.svg b/artwork/icon.svg
new file mode 100644
index 0000000..c2ca180
--- /dev/null
+++ b/artwork/icon.svg
@@ -0,0 +1,100 @@
+
+
diff --git a/makefile b/makefile
index 4b8905f..6e55b9c 100644
--- a/makefile
+++ b/makefile
@@ -13,6 +13,7 @@ build_macos: bundle
set GOARCH=amd64
mkdir -p _output/macos
go build -tags "sqlite_foreign_keys release macos" -ldflags="-s -w" -o _output/macos/yarr main.go
+ cp artwork/icon.png _output/macos/icon.png
go run scripts/package_macos.go _output/macos
build_linux: bundle
diff --git a/scripts/package_macos.go b/scripts/package_macos.go
index dd722b0..1da9ad2 100644
--- a/scripts/package_macos.go
+++ b/scripts/package_macos.go
@@ -3,7 +3,11 @@ package main
import (
"os"
"path"
+ "fmt"
"io/ioutil"
+ "os/exec"
+ "strconv"
+ "log"
)
var plist = `
@@ -24,9 +28,7 @@ var plist = `
yarr
CFBundleIconFile
- AppIcon
- CFBundleIconName
- AppIcon
+ icon
LSApplicationCategoryType
public.app-category.news
@@ -48,19 +50,49 @@ var plist = `
`
+func run(cmd ...string) {
+ fmt.Println(cmd)
+ err := exec.Command(cmd[0], cmd[1:]...).Run()
+ if err != nil {
+ log.Fatal(err)
+ }
+}
+
func main() {
outdir := os.Args[1]
outfile := "yarr"
binDir := path.Join(outdir, "yarr.app", "Contents/MacOS")
resDir := path.Join(outdir, "yarr.app", "Contents/Resources")
- plistPath := path.Join(outdir, "yarr.app", "Contents/Info.plist")
+
+ plistFile := path.Join(outdir, "yarr.app", "Contents/Info.plist")
+ pkginfoFile := path.Join(outdir, "yarr.app", "Contents/PkgInfo")
os.MkdirAll(binDir, 0700)
os.MkdirAll(resDir, 0700)
f, _ := ioutil.ReadFile(path.Join(outdir, outfile))
- ioutil.WriteFile(path.Join(binDir, outfile), f, 0700)
+ ioutil.WriteFile(path.Join(binDir, outfile), f, 0755)
- ioutil.WriteFile(plistPath, []byte(plist), 0600)
+ ioutil.WriteFile(plistFile, []byte(plist), 0644)
+ ioutil.WriteFile(pkginfoFile, []byte("APPL????"), 0644)
+
+ iconFile := path.Join(outdir, "icon.png")
+ iconsetDir := path.Join(outdir, "icon.iconset")
+ os.Mkdir(iconsetDir, 0700)
+
+ for _, res := range []int{1024, 512, 256, 128, 64, 32, 16} {
+ outfile := fmt.Sprintf("icon_%dx%d.png", res, res)
+ if res == 1024 || res == 64 {
+ outfile = fmt.Sprintf("icon_%dx%d@2x.png", res / 2, res / 2)
+ }
+ cmd := []string {
+ "sips", "-s", "format", "png", "--resampleWidth", strconv.Itoa(res),
+ iconFile, "--out", path.Join(iconsetDir, outfile),
+ }
+ run(cmd...)
+ }
+
+ icnsFile := path.Join(resDir, "icon.icns")
+ run("iconutil", "-c", "icns", iconsetDir, "-o", icnsFile)
}