Move the SMC-PAD MIDI intercept into padeditor and add a systemd user service with an installer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
647cfa3a75
commit
00de2595b6
13 files changed
+127
-34
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install the SMC-PAD MIDI intercept as a systemd user service and start it.
|
||||
#
|
||||
# padeditor/systemd/install.sh # install, enable, start
|
||||
# padeditor/systemd/install.sh --lock-knobs # pass options to the intercept
|
||||
# padeditor/systemd/install.sh --uninstall
|
||||
#
|
||||
# Logs: journalctl --user -u smc-pad-intercept -f
|
||||
set -euo pipefail
|
||||
|
||||
UNIT=smc-pad-intercept.service
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
ROOT="$(cd "$HERE/../.." && pwd)"
|
||||
DEST="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
|
||||
if [[ "${1:-}" == "--uninstall" ]]; then
|
||||
systemctl --user disable --now "$UNIT" 2>/dev/null || true
|
||||
rm -f "$DEST/$UNIT"
|
||||
systemctl --user daemon-reload
|
||||
echo "Removed $UNIT."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PYTHON="$ROOT/.venv/bin/python"
|
||||
[[ -x "$PYTHON" ]] || PYTHON="$(command -v python3)"
|
||||
"$PYTHON" -c "import rtmidi" 2>/dev/null || {
|
||||
echo "$PYTHON cannot import rtmidi. Run pipenv install (or pip install python-rtmidi) first." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
ARGS="$*"
|
||||
mkdir -p "$DEST"
|
||||
sed -e "s|@ROOT@|$ROOT|g" -e "s|@PYTHON@|$PYTHON|g" -e "s|@ARGS@|$ARGS|g" \
|
||||
"$HERE/$UNIT" >"$DEST/$UNIT"
|
||||
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable "$UNIT"
|
||||
systemctl --user restart "$UNIT"
|
||||
echo "Installed $DEST/$UNIT and started it."
|
||||
systemctl --user --no-pager status "$UNIT" | head -5 || true
|
||||
@@ -0,0 +1,22 @@
|
||||
# SMC-PAD MIDI intercept (padeditor.intercept) as a systemd user service.
|
||||
# install.sh fills in @ROOT@, @PYTHON@ and @ARGS@ and copies it to
|
||||
# ~/.config/systemd/user/.
|
||||
|
||||
[Unit]
|
||||
Description=SMC-PAD MIDI intercept (virtual port "SMC-PAD Smooth")
|
||||
After=sound.target
|
||||
# Keep retrying while the pad is switched off or not paired yet.
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=@ROOT@
|
||||
ExecStart=@PYTHON@ -m padeditor.intercept @ARGS@
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# The intercept closes its ports on Ctrl+C.
|
||||
KillSignal=SIGINT
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
Reference in new issue
Block a user