BASH SCRIPT FOR QJACKCTL FREEZE, AND FOR SLEEP SCRIPT ALSO

My environment, I’m using xfce4-session-logout command for quit gui-manager session and logout.
I’m using Ubuntu Studio, so it is XFCE gui manager.
Change this command to your GUI manager environment.

Script for qjackctl freezing problem

#!/bin/bash 
#is qjackctl running?
if  ps aux|grep  qjackctl|grep -v grep 
	then
		echo qjackctl is running...
		#kill qjackctl
		kill -9 `ps aux|grep  qjackctl|grep -v grep|awk '{ print $2 }'`
		sleep 1
		#once logout without dialog and save session...
		xfce4-session-logout --fast
else
	echo no qjackctl process...
fi
  1. Judging qjackctl process is running by ps and grep commands
  2. if it’s running, using kill command to quit qjackctl immediately.
    extract process id of qjackctl by using awk command.
    Second row of the result of ps command is the process id.
  3. order to logout once to re-initialize audio environment, especially qjackctl (including jackd(jack daemon)).

My newer OS environment frequently freeze audio environment, especially while watching YouTube movie.
I re-started audio environment by log-out or reboot, but it takes long time for maybe security problem.

Using kill command seems able to quit qjackctl process quickly.
But I have to repeat test of this script through practical using.

And I also introduce my os sleep script for qjackctl users.


MAKE SURE YOUR QJACKCTL SETTING FOR ENABLE_D-BUS_INTERFACE AND SYSTEMCTL COMMAND.
See code comment.

#!/bin/bash
#sleep script for qjackctl users
#jack用のスリープコマンド
#first, stop qjackctl (make sure your setting Setup->Misc->Enable (JACK) D-Bus Interface is checked)
#second kill qjackctl process
#go to sleep mode (make sure you have systemctl command, if you don't have, search alternative command for your OS)
#まずjackを停止して、スリープする

#!/bin/bash 
#is qjackctl running?
if  ps aux|grep  qjackctl|grep -v grep 
	then
		echo qjackctl is running...
		#kill qjackctl
		dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.stop
		sleep 1 
		kill -9 `ps aux|grep  qjackctl|grep -v grep|awk '{ print $2 }'`
		systemctl suspend
		sleep 1
else
	echo no qjackctl process...
	systemctl suspend
fi

I’m using this script, put it to desktop, and execute by clicking icon.
It’s very handy.

(RE)START QJACKCTL SESSION


After come back from sleep, I’m using follow script to re-start qjackctl session.

DON’T FORGET TO CHANGE ONE LINE CONDITIONING STATEMENT TO FIT TO YOUR ENVIRONMENT.

I’m using FireWire type audio-interface FA-101, so I’m using ffado-test command, you should change this line, perhaps to lsusb?
And change grep search word to your audio-interface name.

#!/bin/bash
#if qjackctl is not running, start it
#if my audio-interface connected and found, start qjackctl session
if ps aux|grep qjackctl|grep -v grep
	then
		"qjack is launching"
	else
		echo "no qjack"
		nice -99 qjackctl &
		sleep 3
fi
#CHANGE BELOW IF CONDITIONING STATEMENT TO FIT YOUR ENVIRONMENT
###############################
#if my audio-interface connected and found, start qjackctl session
if ffado-test ListDevices|grep FA-101
	then
		nice -99 dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.start
fi


Maybe you can this script runs automatically, after come back from sleep, by add this script to one directory.

Somewhere directory where will be executed automatically after return…

One thought on “BASH SCRIPT FOR QJACKCTL FREEZE, AND FOR SLEEP SCRIPT ALSO

Leave a comment