#!/bin/bash

# Copyright Piero Olmeda - AudioLinux  audiolinux@fastmail.fm
# https://www.audio-linux.com
# License: custom - All rights reserved
# options "", "xhci|ehci|snd", "echo $APPLICATIONS | sed 's/ /|/g'", "$INTERFACE"

source /etc/rtpriority/rtapp.conf

apps="$(echo $APPLICATIONS | sed 's/ /|/g')"

rtpriority_reset() {
if [[ "$1" = "$apps" ]]; then
    PIDS=`ps -eo pid,comm | grep -E "$1" | awk '{print $1}'`
    echo "$PIDS"
else
	PIDS=`ps -eo pid,comm | grep -E -i "irq.[0-9]+" | grep -E "$1" | awk '{print $1}'`
	echo "$PIDS"
	for PID in $PIDS
	do
		chrt -f -a -p 50 $PID
	done
fi
}

rtpriority_reset $1
