Help with scripts

Hi guys.
I am a qubes-os user for 1 year now. currently running 4.2.1rc with latest kernel.
I wanted to have some tool in my setup which can restrict qube A from starting if Qube B is running. I want to be productive. I have seperated qubes on the basis of each task. So I dont want that I can run multimedia while I am doing work.
In Windows there are utilites like focusme etc.
So Is there a way to write some script which can do this.

A script like this might work for you in dom0:

#/bin/bash

# qubes to stop (separated by space if multiple)
qubes="qube1 qube2 qube3"
# if qube running, stop qubes listed in "qubes"
if_running="qube4"


while :
do
    for qube in $qubes;
    do
        if qvm-check -q --running "$if_running"; then
            if qvm-check -q --running "$qube"; then
                sleep 4 # try to let the qube start normally before asking it to shutdown
                echo "$if_running is active, shutting down $qube ..."
                qvm-shutdown "$qube" --wait --timeout 30
            fi
        fi
    done
    sleep 1
done
2 Likes