8000 GitHub - Vitnir/BazecorTray: Bazecor Tray Application for easier Layer switch
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Vitnir/BazecorTray

Repository files navigation

BazecorTray

BazecorTray is a lightweight cross-platform tray application for interacting with keyboards from Dygma like the Raise or the Defy via its serial API. It runs in the background and allows you to:

  • Select the serial port connected to your keyboard.
  • Select the active layer (0–9) with a single click in the tray menu.
  • Send commands (version, layer.moveTo N) to the keyboard and display responses in the console.
  • View application info (name, version, author).
  • Quit the application cleanly from the tray.

Features

  • Cross-platform tray icon: Supports Windows, macOS, and Linux.
  • Serial port enumeration: Detects available ports and shows USB details (VID:PID, product name).
  • Persistent configuration: Saves the selected port in bazecortray-config.json.
  • Layer management: Quickly switch layers via nested tray menus.
  • Automatic retries: Retries commands if the port is busy for up to 5 seconds.
  • Minimal dependencies: Uses systray, serial, and Go standard library.

Installation

  1. Build the application:
    go build -o bazecortray main.go
  2. Place the binary and icon.png / icon.ico in the same directory.

Icon & Packaging

Windows

  1. Convert your icon.png to a multi-resolution icon.ico using ImageMagick:
    # If ImageMagick is on PATH as 'magick'
    magick icon.png -define icon:auto-resize=64,48,32,16 icon.ico
  2. Embed the icon into the executable with rsrc:
    go install github.com/akavel/rsrc@latest
    rsrc -ico icon.ico -o icon.syso
  3. Build as a GUI application (no console window):
    go build -ldflags="-H windowsgui" -o BazecorTray.exe
    Now BazecorTray.exe will carry the custom icon.

macOS

  1. Create an iconset from icon.png:
    mkdir MyIcon.iconset
    sips -z 16 16     icon.png --out MyIcon.iconset/icon_16x16.png
    sips -z 32 32     icon.png --out MyIcon.iconset/icon_16x16@2x.png
    sips -z 32 32     icon.png --out MyIcon.iconset/icon_32x32.png
    sips -z 64 64     icon.png --out MyIcon.iconset/icon_32x32@2x.png
    sips -z 128 128   icon.png --out MyIcon.iconset/icon_128x128.png
    sips -z 256 256   icon.png --out MyIcon.iconset/icon_128x128@2x.png
    sips -z 256 256   icon.png --out MyIcon.iconset/icon_256x256.png
    sips -z 512 512   icon.png --out MyIcon.iconset/icon_256x256@2x.png
    sips -z 512 512   icon.png --out MyIcon.iconset/icon_512x512.png
    sips -z 1024 1024 icon.png --out MyIcon.iconset/icon_512x512@2x.png
  2. Convert the iconset to .icns:
    iconutil -c icns MyIcon.iconset
    # produces MyIcon.icns
  3. Create your .app bundle structure:
    BazecorTray.app/
      Contents/
        MacOS/
          BazecorTray       ← compiled binary
        Resources/
          MyIcon.icns       ← your icon
        Info.plist
    
  4. Write Contents/Info.plist:
    <?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>BazecorTray</string>
      <key>CFBundleExecutable</key>
        <string>BazecorTray</string>
      <key>CFBundleIconFile</key>
        <string>MyIcon</string>
      <key>CFBundleIdentifier</key>
        <string>de.faier.bazecortray</string>
      <key>CFBundleVersion</key>
        <string>1.0.0</string>
      <key>LSBackgroundOnly</key>
        <true/>
    </dict>
    </plist>
  5. Build for Apple Silicon (ARM64):
    export GOOS=darwin
    export GOARCH=arm64
    go build -o BazecorTray.app/Contents/MacOS/BazecorTray main.go
  6. (Optional) Universal Binary:
    # Intel
    GOOS=darwin GOARCH=amd64 go build -o build/BazecorTray-amd64 main.go
    # ARM64
    GOOS=darwin GOARCH=arm64 go build -o build/BazecorTray-arm64 main.go
    # Merge
    lipo -create build/BazecorTray-amd64 build/BazecorTray-arm64         -output BazecorTray.app/Contents/MacOS/BazecorTray

Linux

  1. Install the binary (e.g. /usr/local/bin/bazecortray) and icon (.png) to /usr/local/share/icons.
  2. Create /usr/share/applications/bazecortray.desktop:
    [Desktop Entry]
    Type=Application
    Name=BazecorTray
    Exec=/usr/local/bin/bazecortray
    Icon=/usr/local/share/icons/bazecortray.png
    Categories=Utility;
    StartupNotify=false
  3. Autostart via user autostart:
    # ~/.config/autostart/bazecortray.desktop
    [Desktop Entry]
    Type=Application
    Name=BazecorTray
    Exec=/usr/local/bin/bazecortray
    X-GNOME-Autostart-enabled=true

Usage

Run the application:

./bazecortray
  • It will appear in your system tray.
  • Click 📟 Select Port → choose the serial port.
  • Click 🎛️ Select Layer → pick a layer (default is 2 on Windows/Linux, 0 on macOS).
  • Click ℹ️ Info to print version and author to the console.
  • Click 🚪 Quit to exit.

Configuration

  • The selected serial port is stored in bazecortray-config.json:

    {
      "Port": "COM5"
    }
  • You can manually edit this file if needed.

License

This project is licensed under the Apache License 2.0.

Attribution Requirement:
You must include the following statement in any distribution or derivative work:

This software includes code by Lars Faier.

Failure to do so violates the terms of the license.

License File

Include a copy of the full Apache License 2.0 text in a LICENSE file in your distribution.

About

Bazecor Tray Application for easier Layer switch

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0