Writing “sleep or suspend script” for JACK and qjackctl

JACK is weak for suspend because it needs to be stopped and restarted when come back from suspend. So I’m trying to write suspend script which stop JACK before go to suspend mode and start after come back from sleep.

First stop and start qjackctl command is below.

dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.stop

 

dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.start

 

Now I have very simple script that very useful when come back from suspend mode because it stop and restart qjackctl automatically. That is

#!/bin/bash
dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.stop && dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.start

Actually this is enough useful. Lol. But I will try to make better one.

It use

sudo pm-suspend

command. The problem is needs sudoers configuration to use pm-suspend command.
Without this “sudo pm-suspend” in bash shell script won’t do anything.

sudo -S pm-suspend

will work, it receives password from a terminal and will suspend.
And this is almost perfect except for security problem

password='Hacker\'s password'
echo $password | sudo -S pm-suspend

It won’t require to input password interactively.

#!/bin/bash
#Suspend script for JACK(qjackctl)
#First stop JACK and go to suspend
dbus-send --system /org/rncbc/qjackctl org.rncbc.qjackctl.stop
password='********'
echo $password | sudo -S pm-suspend

Then, this should be assigned with hot key on GUI manager on Ubuntu.

And I guess restart script is harder because I should research mechanism and the script path which automatically done when return from suspend mode.

My plan was logging about sudoers configuration but now I think i can go with this.

I will write again soon. Bye.😀

 

 

 

Advertisements

Changing Display Brightness on iMac Ubuntu

Screenshot from 2018-10-20 11-32-35.png

My iMac Ubuntu is hard to change display brightness.

It needs terminal command. By the way have to burn chips again😍 Repair man!

change

/sys/class/backlight/radeon_bl1/brightness

file by text editor or

echo 100 | sudo tee brightness

I was making shell script to do this like

#!/bin/bash
#To change iMac display brightness

echo $1 | sudo tee /sys/class/backlight/radeon_bl1/brightness

But use sudo command in a shell script is pretty hard.

And

sudo "User Command"

results

masa@em-p:/sys/class/backlight/radeon_bl1$ sudo iMacDisplay02.sh 
sudo: iMacDisplay02.sh: command not found

Because of /etc/sudoers .

Recommended edit by visudo.

Tough!!😊