adding mac support mainly

This commit is contained in:
lwoodard
2026-04-13 08:11:19 -06:00
parent 9c681e482e
commit 0f5a136764
9 changed files with 657 additions and 190 deletions

View File

@@ -1,16 +1,29 @@
BINARY := streamdeck-go
HELPER := streamdeck-helper
PREFIX ?= $(HOME)/.local
BIN_DIR := $(PREFIX)/bin
SYS_BIN := /usr/local/bin
CONFIG_DIR := $(HOME)/.config/streamdeck-go
SYSTEMD_USER := $(HOME)/.config/systemd/user
SYSTEMD_SYS := /etc/systemd/system
ETC_DIR := /etc/streamdeck-go
UDEV_RULE := /etc/udev/rules.d/99-streamdeck.rules
GROUP := streamdeck
.PHONY: build build-helper install install-helper uninstall udev
# ── OS detection ──────────────────────────────────────────────────────────────
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
BIN_DIR := $(HOME)/go/bin
ETC_DIR := /usr/local/etc/streamdeck-go
LAUNCHAGENTS := $(HOME)/Library/LaunchAgents
LAUNCHDAEMONS := /Library/LaunchDaemons
AGENT_PLIST := $(LAUNCHAGENTS)/com.woodarddigital.streamdeck-go.plist
DAEMON_PLIST := $(LAUNCHDAEMONS)/com.woodarddigital.streamdeck-go-helper.plist
else
BIN_DIR := $(PREFIX)/bin
SYS_BIN := /usr/local/bin
ETC_DIR := /etc/streamdeck-go
SYSTEMD_USER := $(HOME)/.config/systemd/user
SYSTEMD_SYS := /etc/systemd/system
UDEV_RULE := /etc/udev/rules.d/99-streamdeck.rules
endif
.PHONY: build build-helper install install-helper uninstall uninstall-helper udev
# ── Build ─────────────────────────────────────────────────────────────────────
@@ -22,25 +35,37 @@ build-helper:
# ── Install ───────────────────────────────────────────────────────────────────
# Interactive install — prompts for dotfiles directory, creates symlink,
# installs binary + udev rule + systemd user service.
# Interactive install — prompts for dotfiles directory, installs binary + service.
install:
@bash install.sh
# Install the privileged helper (requires sudo).
# Creates a 'streamdeck' group, adds the current user to it, installs the
# helper binary as root, and enables it as a system service.
ifeq ($(OS),Darwin)
# On macOS there is no root daemon — privileged commands run via osascript (admin
# auth dialog). install-helper just drops the whitelist into the user config dir.
install-helper:
mkdir -p $(CONFIG_DIR)
@if [ ! -f $(CONFIG_DIR)/privileged.yaml ]; then \
install -m 644 config/privileged.example.yaml $(CONFIG_DIR)/privileged.yaml; \
echo "Whitelist written to $(CONFIG_DIR)/privileged.yaml"; \
else \
echo "Whitelist already exists — not overwriting"; \
fi
@echo ""
@echo "Edit $(CONFIG_DIR)/privileged.yaml to add priv: commands."
@echo "No sudo or daemon required — macOS will prompt for admin auth on use."
else
install-helper: build-helper
# Create group and add current user.
# Create group and add current user (Linux).
@if ! getent group $(GROUP) > /dev/null; then \
sudo groupadd $(GROUP); \
echo "Created group '$(GROUP)'"; \
fi
sudo usermod -aG $(GROUP) $(USER)
# Install helper binary (owned root, not world-executable by others).
# Install helper binary (owned root, not world-executable).
sudo install -Dm750 $(HELPER) $(SYS_BIN)/$(HELPER)
sudo chown root:$(GROUP) $(SYS_BIN)/$(HELPER)
# Install whitelist config (root-owned, not world-writable).
# Install whitelist config.
sudo mkdir -p $(ETC_DIR)
@if [ ! -f $(ETC_DIR)/privileged.yaml ]; then \
sudo install -Dm640 config/privileged.example.yaml $(ETC_DIR)/privileged.yaml; \
@@ -57,8 +82,13 @@ install-helper: build-helper
@echo "Helper installed. Edit $(ETC_DIR)/privileged.yaml (as root) to add commands."
@echo "NOTE: log out and back in for group membership to take effect,"
@echo " or run: newgrp $(GROUP)"
endif
# udev: Linux-only device permission rule.
udev:
ifeq ($(OS),Darwin)
@echo "udev is Linux-only — not needed on macOS (IOKit grants HID access directly)."
else
@if [ ! -f $(UDEV_RULE) ]; then \
echo 'KERNEL=="hidraw*", ATTRS{idVendor}=="0fd9", MODE="0666"' \
| sudo tee $(UDEV_RULE); \
@@ -68,9 +98,21 @@ udev:
else \
echo "udev rule already exists."; \
fi
endif
# ── Uninstall ─────────────────────────────────────────────────────────────────
ifeq ($(OS),Darwin)
uninstall:
launchctl unload $(AGENT_PLIST) 2>/dev/null || true
rm -f $(AGENT_PLIST)
rm -f $(BIN_DIR)/$(BINARY)
@echo "Uninstalled. Config at $(CONFIG_DIR) preserved."
uninstall-helper:
@echo "No helper daemon on macOS — nothing to uninstall."
@echo "Whitelist at $(CONFIG_DIR)/privileged.yaml preserved."
else
uninstall:
systemctl --user disable --now streamdeck-go.service || true
rm -f $(BIN_DIR)/$(BINARY)
@@ -84,3 +126,4 @@ uninstall-helper:
sudo rm -f $(SYSTEMD_SYS)/streamdeck-go-helper.service
sudo systemctl daemon-reload
@echo "Helper uninstalled. Whitelist at $(ETC_DIR)/privileged.yaml preserved."
endif