Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,31 @@ jobs:
CGO_ENABLED=1 GOARCH=$arch go build -o "$dir/bpm-tray" ./cmd/bpm-tray
tar -C "$dir" -czf "dist-tray/bpm-tray_${{ github.ref_name }}_darwin_${arch}.tar.gz" bpm-tray
done
- name: Build AppIcon.icns from the embedded logo
run: |
mkdir -p /tmp/icon.iconset
for size in 16 32 128 256 512; do
sips -z $size $size internal/webui/assets/logo.png --out /tmp/icon.iconset/icon_${size}x${size}.png >/dev/null
double=$((size*2))
sips -z $double $double internal/webui/assets/logo.png --out /tmp/icon.iconset/icon_${size}x${size}@2x.png >/dev/null
done
iconutil -c icns /tmp/icon.iconset -o /tmp/AppIcon.icns
- name: Assemble BpmTray.app for both architectures
run: |
version="${{ github.ref_name }}"
version="${version#v}"
for arch in arm64 amd64; do
app="dist-tray/darwin_${arch}/BpmTray.app"
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
sed "s/VERSION_PLACEHOLDER/${version}/" packaging/macos/Info.plist.template > "$app/Contents/Info.plist"
cp "dist-tray/darwin_${arch}/bpm-tray" "$app/Contents/MacOS/bpm-tray"
cp /tmp/AppIcon.icns "$app/Contents/Resources/AppIcon.icns"
plutil -lint "$app/Contents/Info.plist"
ditto -c -k --sequesterRsrc --keepParent "$app" "dist-tray/BpmTray_${{ github.ref_name }}_darwin_${arch}.zip"
done
- name: Attach to the release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ github.ref_name }} dist-tray/*.tar.gz --clobber
run: |
gh release upload ${{ github.ref_name }} dist-tray/*.tar.gz --clobber
gh release upload ${{ github.ref_name }} dist-tray/*.zip --clobber
19 changes: 17 additions & 2 deletions cmd/bpm-tray/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,20 @@ func main() {
}

func onReady() {
systray.SetIcon(webui.LogoPNG)
// Template icon: a flat black silhouette with real alpha, so macOS tints
// it correctly for the light/dark menu bar - the full-colour app icon
// (via plain SetIcon) rendered as an illegible colour blob at actual
// menu bar size. regularIconBytes (LogoPNG) is only a fallback for
// platforms without template-icon support; bpm-tray only ships for
// macOS, so it's never actually shown.
systray.SetTemplateIcon(webui.LogoTemplatePNG, webui.LogoPNG)
systray.SetTooltip("Bambu Profile Manager")

// A single click opens the web UI directly - no menu to navigate first.
// Right-click (the systray default when SetOnTapped is set) still shows
// the menu below, so Quit stays reachable.
systray.SetOnTapped(openBrowser)

mOpen := systray.AddMenuItem("Open bpm", "Open the web UI in your browser")
mStatus := systray.AddMenuItem("Starting…", "")
mStatus.Disable()
Expand All @@ -51,7 +62,7 @@ func onReady() {
for {
select {
case <-mOpen.ClickedCh:
exec.Command("open", "http://localhost"+addr).Start()
openBrowser()
case <-mQuit.ClickedCh:
systray.Quit()
return
Expand All @@ -60,6 +71,10 @@ func onReady() {
}()
}

func openBrowser() {
exec.Command("open", "http://localhost"+addr).Start()
}

// startServer wires up the same server cmd/bpm's `serve` builds, but with
// zero flags: db and backups live under ~/Library/Application Support/bpm,
// and Bambu Studio's real directories are auto-discovered rather than
Expand Down
10 changes: 10 additions & 0 deletions internal/webui/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ import (
//go:embed assets/logo.png
var LogoPNG []byte

// LogoTemplatePNG is a monochrome (black-on-transparent) silhouette derived
// from LogoPNG, cropped and downsized for use as a macOS menu bar "template"
// image — those get tinted/inverted automatically for the light/dark menu
// bar, but only if they're a flat black shape with real alpha, not a full
// colour icon (real gap found live: SetIcon with the full-colour app icon
// rendered as a tiny, illegible blob at menu bar size).
//
//go:embed assets/logo-template.png
var LogoTemplatePNG []byte

// handleLogo serves LogoPNG over HTTP. Aggressively cacheable: the file
// only changes on a new build, and go:embed gives every build a fresh byte
// slice anyway.
Expand Down
Binary file added internal/webui/assets/logo-template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions packaging/macos/Info.plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Bpm Tray</string>
<key>CFBundleDisplayName</key>
<string>Bpm Tray</string>
<key>CFBundleIdentifier</key>
<string>uk.syscode-labs.bpm-tray</string>
<key>CFBundleExecutable</key>
<string>bpm-tray</string>
<key>CFBundleIconFile</key>
<string>AppIcon</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>VERSION_PLACEHOLDER</string>
<key>CFBundleVersion</key>
<string>VERSION_PLACEHOLDER</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
Loading