diff --git a/README.md b/README.md index 740c302..89cf04e 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,22 @@ I am open to supporting other window systems if there is sufficient interest. Download the script (via `curl` or `wget`) and `chmod +x pa-xtouch-control` to make it executable. Then run it with `./pa-xtouch-control` and test your Behringer X-Touch Mini to make sure everything is working. -# Installation as a daemon - TODO +# Installation as a daemon (`systemd`) +1. Download the `pa_xtouch_control.sh` and `pa_xtouch_control.service` files. +2. Make the `pa_xtouch_control.sh` script executable with `chmod +x pa_xtouch_control.sh`. +3. Place `pa_xtouch_control.sh` into `/usr/bin/` with `mv pa_xtouch_control.sh /usr/bin/`. +4. Place `pa_xtouch_control.service` into `~/.config/systemd/user/` (just 'user', not your username) with `mv pa_xtouch_control.service ~/.config/systemd/user/` +5. Create this directory if it does not already exist `mkdir -p ~/.config/systemd/user/`. +6. Reload systemd with `systemctl --user daemon-reload`. +7. Enable autostart of the systemd service with `systemctl --user enable pa_xtouch_control.service`. +8. Start the service with `systemctl --user start pa_xtouch_control.service`. + +You can do all of these steps with: + +```bash + +``` + # Modifying the script diff --git a/pa_xtouch_control.service b/pa_xtouch_control.service new file mode 100644 index 0000000..62b4d8f --- /dev/null +++ b/pa_xtouch_control.service @@ -0,0 +1,8 @@ +[Unit] +Description=PulseAudio X-Touch control daemon + +[Service] +ExecStart=/usr/bin/pa_xtouch_control.sh + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/pa_xtouch_control.sh b/pa_xtouch_control.sh index 3b2f235..02b244b 100644 --- a/pa_xtouch_control.sh +++ b/pa_xtouch_control.sh @@ -197,9 +197,17 @@ get_stream_index_from_pid(){ done } -get_pid_from_binary(){ - # todo - echo "Not yet implemented" +get_binary_from_pid(){ + output="$(paste -d"\t" \ + <(printf '%s' "$output" | grep 'application.process.id' | cut -d'"' -f 2) \ + <(printf '%s' "$output" | grep 'application.process.binary' | cut -d'"' -f 2))" + + echo "$output" | while read line ; do + pid=$(echo "$line" | cut -f1) + if [[ "$pid" == "$1" ]]; then + echo "$line" | cut -f2 + fi + done } bind_application() {