#!/bin/sh

MUSIC_PATH

=

"/tmp/GetWild.m4a"

()

{

if

[

!

-f

$(

)

]

;

then

echo

"Please install NoSleepCtrl from "

echo

" https://github.com/integralpro/nosleep/releases"

echo

" "

echo

"Install it with CLI included in it. It's necessary to prevent"

echo

"your macbook from going to sleep when somebody closes the clamshell."

echo

"When you launch this script it will automatically turn the 'NoSleep'"

echo

"mode ON and when you exit the script with Ctrl-C, the 'NoSleep' mode"

echo

"will automatically be turned OFF."

echo

"(You are not required to be running it in the tray)"

echo

" "

exit

fi

}

()

{

local

volume

=

$(

-e

"(get volume settings)'s output volume"

)

local

muted

=

$(

-e

"(get volume settings)'s output muted"

)

while

;

do

-a

-s

-b

-s

-e

"set volume 100"

sleep

done

local

pid

=

$!

trap

" NoSleepCtrl -a -s 0 NoSleepCtrl -b -s 0 kill

$pid

osascript -e 'set volume output volume

$volume

' osascript -e 'set volume output muted

$muted

' exit "

}

()

{

[

$(

-r

-k

-d

grep

head

-1

cut

-d

=

-f

)

=

]

}

()

{

# Check NoSleepCtrl available

# Init local variables

local

intrusion_detected

=

false local

counter

=

# Launch volume forcer

# Execution loop

while

;

do if

$intrusion_detected

||

$(

)

;

then

let

counter

=

-v

"爆破スイッチが起動されました"

-v

"5秒後に爆発します"

while

[

$counter

-gt

]

;

do

-v

$counter

let

=

sleep

done

$MUSIC_PATH

intrusion_detected

=

true

fi

sleep

done

}