From 825f0598a47f67e6bc618b7a57ac545fd94949b4 Mon Sep 17 00:00:00 2001 From: Luke Tidd Date: Sat, 26 Apr 2025 12:05:34 -0400 Subject: [PATCH] check in user systemd services and pulse auto connect --- bin/pulse_jack_autoconnect | 41 +++++++++++++++++++++++++ config/systemd/user/ardour.service | 15 +++++++++ config/systemd/user/carla.service | 14 +++++++++ config/systemd/user/carla_pre.service | 11 +++++++ config/systemd/user/jack.service | 14 +++++++++ config/systemd/user/patchage.service | 14 +++++++++ config/systemd/user/pavucontrol.service | 14 +++++++++ config/systemd/user/pulse_jack.service | 12 ++++++++ 8 files changed, 135 insertions(+) create mode 100755 bin/pulse_jack_autoconnect create mode 100644 config/systemd/user/ardour.service create mode 100644 config/systemd/user/carla.service create mode 100644 config/systemd/user/carla_pre.service create mode 100644 config/systemd/user/jack.service create mode 100644 config/systemd/user/patchage.service create mode 100644 config/systemd/user/pavucontrol.service create mode 100644 config/systemd/user/pulse_jack.service diff --git a/bin/pulse_jack_autoconnect b/bin/pulse_jack_autoconnect new file mode 100755 index 0000000..442a3c7 --- /dev/null +++ b/bin/pulse_jack_autoconnect @@ -0,0 +1,41 @@ +#!/bin/bash + +declare -A ports +ports[pulsel]='PulseAudio JACK Sink:front-left' +ports[pulser]='PulseAudio JACK Sink:front-right' +ports[echo_audiofire1]='firewire_pcm:001486a296a59815_Unknown_out' +ports[echo_audiofire2]='firewire_pcm:001486a296a59815_Unknown0_out' + +retries=10 +err_file="$(mktemp)" +while [[ "$retries" -gt 0 ]]; do + failed=false + live_ports="$(jack_lsp -c 2>"$err_file")" + printf 'live ports:\n\n%s\n' "$live_ports" + err="$(<"$err_file")" + rm "$err_file" + if [[ -n "$err" ]]; then + printf '%s\n' "$err" >&2 + sleep 2 + ((retries-=1)) + continue + fi + for port in "${ports[@]}"; do + if ! grep -q "$port" <<< "$live_ports"; then + printf '%s not seen\n' "$port" >&2 + sleep 2 + ((retries-=1)) + failed=true + fi + done + if [[ "$failed" == 'false' ]]; then + break + fi +done + +jack_connect "${ports[pulsel]}" "${ports[echo_audiofire1]}" +jack_connect "${ports[pulser]}" "${ports[echo_audiofire2]}" +printf 'success\n' +if [[ "$retries" != 10 ]]; then + printf 'attempts: %s\n' "$((10-retries))" +fi diff --git a/config/systemd/user/ardour.service b/config/systemd/user/ardour.service new file mode 100644 index 0000000..35205de --- /dev/null +++ b/config/systemd/user/ardour.service @@ -0,0 +1,15 @@ +[Unit] +Description=ardour +After=carla_pre.service +Wants=carla_pre.service + +[Service] +Environment="DISPLAY=:0" +Environment="XAUTHORITY=/home/luke/.Xauthority" +StandardOutput=syslog+console +StandardError=syslog+console +ExecStart=/home/luke/bin/ardour_with_template +Restart=always +RestartSec=5 +[Install] +WantedBy=default.target diff --git a/config/systemd/user/carla.service b/config/systemd/user/carla.service new file mode 100644 index 0000000..ef6a6f6 --- /dev/null +++ b/config/systemd/user/carla.service @@ -0,0 +1,14 @@ +[Unit] +Description=carla +After=carla_pre.service + + +[Service] +Environment="DISPLAY=:0" +StandardOutput=syslog+console +StandardError=syslog+console +Environment="XAUTHORITY=/home/luke/.Xauthority" +ExecStart=/usr/bin/carla /studio/carla/default.carxp + +[Install] +WantedBy=graphical.target diff --git a/config/systemd/user/carla_pre.service b/config/systemd/user/carla_pre.service new file mode 100644 index 0000000..591602f --- /dev/null +++ b/config/systemd/user/carla_pre.service @@ -0,0 +1,11 @@ +[Unit] +Description=carla_pre +After=graphical.target + + +[Service] +Type=exec +ExecStart=/home/luke/bin/prestart_carla + +[Install] +WantedBy=graphical.target diff --git a/config/systemd/user/jack.service b/config/systemd/user/jack.service new file mode 100644 index 0000000..7ddeee5 --- /dev/null +++ b/config/systemd/user/jack.service @@ -0,0 +1,14 @@ +[Unit] +Description=JACK +#Before=pulseaudio.service pulseaudio.socket +[Service] +LimitRTPRIO=infinity +LimitMEMLOCK=infinity +ExecStart=/usr/bin/jackd -dfirewire -r48000 -p256 -n3 +# ExecStart=/usr/bin/jackd -dfirewire -r44100 -p256 -n3 +# ExecStart=/usr/bin/jackd -dfirewire -r48000 -p128 -n3 +# ExecStart=/usr/bin/jackd -dalsa -dhw:AudioFire12_1,0 -r48000 -p128 -n3 -i24 -o24 +Restart=always +RestartSec=5 +[Install] +WantedBy=default.target diff --git a/config/systemd/user/patchage.service b/config/systemd/user/patchage.service new file mode 100644 index 0000000..5ba517e --- /dev/null +++ b/config/systemd/user/patchage.service @@ -0,0 +1,14 @@ +[Unit] +Description=patchage +After=carla_pre.service + + +[Service] +Environment="DISPLAY=:0" +StandardOutput=syslog+console +StandardError=syslog+console +Environment="XAUTHORITY=/home/luke/.Xauthority" +ExecStart=/usr/bin/patchage + +[Install] +WantedBy=graphical.target diff --git a/config/systemd/user/pavucontrol.service b/config/systemd/user/pavucontrol.service new file mode 100644 index 0000000..c2352ab --- /dev/null +++ b/config/systemd/user/pavucontrol.service @@ -0,0 +1,14 @@ +[Unit] +Description=pavucontrol +After=carla_pre.service + + +[Service] +Environment="DISPLAY=:0" +StandardOutput=syslog+console +StandardError=syslog+console +Environment="XAUTHORITY=/home/luke/.Xauthority" +ExecStart=/usr/bin/pavucontrol + +[Install] +WantedBy=graphical.target diff --git a/config/systemd/user/pulse_jack.service b/config/systemd/user/pulse_jack.service new file mode 100644 index 0000000..353299d --- /dev/null +++ b/config/systemd/user/pulse_jack.service @@ -0,0 +1,12 @@ +[Unit] +Description=Pulse_and_Jack +After=jack.service +Wants=jack.service +[Service] +Type=oneshot +ExecStart=/home/luke/bin/pulse_jack +ExecStop=/usr/bin/pactl unload-module module-jack-sink +SuccessExitStatus=0 +RemainAfterExit=true +[Install] +WantedBy=default.target